coupon.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view>
  3. <view v-if="list.length > 0">
  4. <view class="co-title"></view>
  5. <view class="co-list">
  6. <view :class="item.status == 1 ? 'co-status1 co-item':'co-status2 co-item'" v-for="(item,index) in list">
  7. <view class="co-left">
  8. <view class="co-title">{{item.title}}</view>
  9. <view class="co-over">过期时间: {{item.over}}</view>
  10. </view>
  11. <view class="co-right">
  12. <view class="co-price">{{item.price}}</view>
  13. <view class="co-status">{{item.status_title}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="nodata_box" v-if="list.length==0">
  19. <image src="/static/user/no_data_img.png" mode="" style="width: 220rpx; height: 302rpx;"></image>
  20. <text>暂无数据</text>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. list: {},
  29. user_id: '',
  30. }
  31. },
  32. onLoad() {
  33. if (uni.getStorageSync('id')) {
  34. this.getInfo();
  35. this.show = true;
  36. } else {
  37. // #ifdef MP
  38. this.mpLogin()
  39. return
  40. uni.showToast({
  41. title: '请先登录'
  42. })
  43. // #endif
  44. }
  45. },
  46. methods: {
  47. getInfo() {
  48. let that = this;
  49. let user_id = uni.getStorageSync('id');
  50. this.$post({
  51. data: {
  52. do: 'CouponList',
  53. data: {
  54. user_id: user_id,
  55. }
  56. }
  57. }).then(res => {
  58. that.list = res.data
  59. })
  60. },
  61. // 小程序登录
  62. mpLogin() {
  63. let that = this;
  64. uni.login({
  65. provider: 'weixin',
  66. success: (res) => {
  67. console.log(res, 'rrrrrr')
  68. const code = res.code
  69. this.$post({
  70. data: {
  71. do: 'Login',
  72. data: {
  73. code
  74. }
  75. }
  76. }).then(res => {
  77. this.logininfo = res.data
  78. uni.showModal({
  79. title: '提示',
  80. content: '是否进行头像和昵称授权',
  81. success: (res) => {
  82. if (res.confirm) {
  83. this.getnickImage()
  84. }
  85. }
  86. })
  87. })
  88. }
  89. })
  90. },
  91. getnickImage() {
  92. console.log(this.logininfo.id)
  93. uni.getUserProfile({
  94. desc: '用于昵称和头像的展示',
  95. success: res => {
  96. console.log(res, '++++')
  97. console.log({
  98. user_id: this.logininfo.id,
  99. nickName: res.userInfo.nickName,
  100. avatarUrl: res.userInfo.avatarUrl
  101. })
  102. this.$post({
  103. data: {
  104. do: 'UpdateUser',
  105. data: {
  106. user_id: this.logininfo.id,
  107. nickName: res.userInfo.nickName,
  108. avatarUrl: res.userInfo.avatarUrl
  109. }
  110. }
  111. }).then(res => {
  112. console.log(res, 'rrrrrrrrrr')
  113. for (let i in this.logininfo) {
  114. uni.setStorageSync(i, this.logininfo[i])
  115. }
  116. this.type == 0;
  117. this.getuserinfo();
  118. })
  119. // this.nickName = res.userInfo.nickName
  120. // this.avatarUrl = res.userInfo.avatarUrl
  121. // this.country = res.userInfo.country
  122. // this.province = res.userInfo.province
  123. // this.city = res.userInfo.city
  124. // this.gender = res.userInfo.gender
  125. // uni.login({
  126. // provider: 'weixin',
  127. // success: (res) => {
  128. // this.loginCode = res.code
  129. // uni.hideLoading()
  130. // this.popShow = true
  131. // },
  132. // })
  133. },
  134. fail: (err) => {
  135. uni.hideLoading()
  136. }
  137. })
  138. },
  139. }
  140. }
  141. </script>
  142. <style>
  143. .nodata_box{
  144. display: flex;
  145. flex-direction: column;
  146. justify-content: center;
  147. align-items: center;
  148. margin: 0 auto;
  149. margin-top: 250rpx;
  150. }
  151. .co-left {
  152. width: 85%;
  153. }
  154. .co-item {
  155. display: flex;
  156. margin: 20rpx;
  157. padding: 35rpx;
  158. border-radius: 30rpx;
  159. align-items: center;
  160. }
  161. .co-title {
  162. font-size: 50rpx;
  163. margin: 0 0 20rpx;
  164. }
  165. .co-price {
  166. font-size: 40rpx;
  167. }
  168. .co-status1{
  169. background-color: #ffdada;
  170. }
  171. .co-status2{
  172. background-color: #f1f1f1;
  173. }
  174. </style>