activateFace.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view style="background-color: #FFFFFF;height: 100vh;">
  3. <view class="" v-if="vuex_appletType==1">
  4. <view v-if="faceList!=null && faceList.length!=0">
  5. <view class="head">请选择人脸套餐:</view>
  6. <view class="content">
  7. <view class="faceList">
  8. <view v-for="(item, index) in faceList" :key="index" class="item" @tap="selectFace" :data-item="item" :data-index="index" :style="'border-color:' + (selectIndex==index?'#1296db':'gray')">
  9. <view class="day">{{item.days}}天</view>
  10. <view class="amount">售价{{item.amount}}元</view>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="faceDate">
  15. 人脸有效期:<text>{{faceEndDate}}</text>
  16. </view>
  17. <view @click="goPay" class=" footer-fixed" >
  18. <view class="cu-btn flex text-lg bg-red-btn" style="padding: 46rpx 0;">
  19. 支付
  20. </view>
  21. </view>
  22. </view>
  23. <view v-else>
  24. <view class="default" >
  25. <image src="/static/common/empty.png" mode="heightFix"></image>
  26. <view>
  27. <text>没有相关信息</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view v-else>
  33. <view class="" style="height: 300rpx;"></view>
  34. <u-empty ></u-empty>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. // pages/myFamily/activateFace/activateFace.js
  40. let app = getApp();
  41. export default {
  42. data() {
  43. return {
  44. // 小程序审核状态,0审核中,1审核通过
  45. //目的是为了隐藏wei gui的人脸功能
  46. appletType:0,
  47. user_id: '',
  48. room_id: '',
  49. residential_id: '',
  50. face_charge_id: '',
  51. faceList: [],
  52. selectIndex: null,
  53. faceEndDate: ''
  54. };
  55. },
  56. components: {},
  57. props: {},
  58. /**
  59. * 生命周期函数--监听页面加载
  60. */
  61. onLoad: function (options) {
  62. this.user_id = options.user_id;
  63. this.room_id = options.room_id;
  64. if (uni.getStorageSync("residentialId")) {
  65. this.residential_id = uni.getStorageSync("residentialId");
  66. } else {
  67. uni.showToast({
  68. title: '请先在首页选择所在小区',
  69. icon: 'none'
  70. });
  71. return;
  72. }
  73. this.getFaceList();
  74. },
  75. onShow() {
  76. this.appletType=this.$setNavigationBarTitle('套餐','人脸激活')
  77. console.log(this.appletType);
  78. },
  79. /**
  80. * 生命周期函数--监听页面初次渲染完成
  81. */
  82. onReady: function () {},
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide: function () {},
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload: function () {},
  91. /**
  92. * 页面相关事件处理函数--监听用户下拉动作
  93. */
  94. onPullDownRefresh: function () {},
  95. /**
  96. * 页面上拉触底事件的处理函数
  97. */
  98. onReachBottom: function () {},
  99. /**
  100. * 用户点击右上角分享
  101. */
  102. onShareAppMessage: function () {},
  103. methods: {
  104. selectFace(e) {
  105. let item = e.currentTarget.dataset.item;
  106. let index = e.currentTarget.dataset.index;
  107. this.setData({
  108. face_charge_id: item.id,
  109. selectIndex: index
  110. });
  111. },
  112. getFaceList: function () {
  113. var that = this;
  114. let params = {};
  115. params['residential_id'] = this.residential_id;
  116. params['user_id'] = this.user_id;
  117. let operation = 'userFace/getFaceChargeListByResidentialId';
  118. app.globalData.postRequest(params, operation, function (res) {
  119. console.info("获取成功" + res.data.result_msg);
  120. if (res.data.result_code == 1) {
  121. that.setData({
  122. faceEndDate: res.data.faceEndDate,
  123. faceList: res.data.list
  124. });
  125. }
  126. });
  127. },
  128. goPay: function () {
  129. if (this.face_charge_id == '' || this.face_charge_id == null) {
  130. uni.showToast({
  131. title: '请先选择人脸套餐',
  132. icon: 'none'
  133. });
  134. return;
  135. }
  136. let params = {};
  137. params['residential_id'] = this.residential_id;
  138. params['user_id'] = this.user_id;
  139. params['face_charge_id'] = this.face_charge_id;
  140. params['room_id'] = this.room_id;
  141. let operation = 'userFace/activeFace';
  142. app.globalData.postRequest(params, operation, function (res) {
  143. console.info("获取成功" + res.data.result_msg);
  144. if (res.data.result_code == 1) {
  145. uni.showToast({
  146. title: '激活成功',
  147. icon: 'none'
  148. });
  149. }
  150. });
  151. }
  152. }
  153. };
  154. </script>
  155. <style lang="scss">
  156. .head{
  157. line-height: 100rpx;
  158. margin-left: 20rpx
  159. }
  160. .content{
  161. width: 100%;
  162. }
  163. .faceList{
  164. margin: 0 10rpx;
  165. display: flex;
  166. justify-content: space-between;
  167. flex-wrap: wrap;
  168. }
  169. .item{
  170. width:30%;
  171. display: flex;
  172. flex-direction: column;
  173. align-content: center;
  174. justify-content: center;
  175. text-align: center;
  176. border-radius: 10rpx;
  177. border-style: solid;
  178. border-width: 2rpx;
  179. margin: 10rpx
  180. }
  181. .day{
  182. height:80rpx;
  183. line-height: 80rpx;
  184. font-size: 35rpx;
  185. }
  186. .amount{
  187. color:#1296db;
  188. height:90rpx;
  189. }
  190. .faceDate{
  191. position: fixed;
  192. bottom: 150rpx;
  193. width: 100%;
  194. height: 100rpx;
  195. line-height: 100rpx;
  196. text-align: center;
  197. }
  198. .faceDate text{
  199. color:#1296db;
  200. }
  201. .default { text-align: center; position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);}.default text{ color: #AAAAAA;}.default image { height: 280rpx; display: inline-block;}
  202. </style>