activateFace.vue 4.9 KB

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