myGreenCard.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view class="content">
  3. <view class="" style="height: 20rpx;"></view>
  4. <empty v-if="list.length === 0 && loaded"></empty>
  5. <view class="green-card-wrap" v-for="(gitem,gindex) in list" :key="gindex">
  6. <image :src="'../../static/img/green' +((gitem.id+1)%5) + '.png'" mode="" class="card-bg"></image>
  7. <view class="card-info flex">
  8. <image :src="'../../static/img/ginfo' +((gitem.id+1)%5) + '.png'" mode="" class="info-img"></image>
  9. <view class="info-detail">
  10. <view class="card-name">
  11. 通行绿卡
  12. </view>
  13. <!-- 1买 2赠 -->
  14. <view class="card-from">
  15. 来源:{{gitem.type == 1?'绿积分兑换': '赠送获得'}}
  16. </view>
  17. <view class="card-time">
  18. 获得时间:{{gitem.create_time}}
  19. </view>
  20. </view>
  21. <view class="card-btn-wrap flex" v-if="gitem.status == 0 && gitem.type == 1">
  22. <view class="card-btn" @click="openZs(gitem)">
  23. 转赠
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <uni-load-more :status="loadingType"></uni-load-more>
  29. <uni-popup ref="popup" type="center">
  30. <view class="zs-wrap">
  31. <view class="zs-tit">
  32. 赠送绿卡
  33. </view>
  34. <view class="zs-uid flex">
  35. <view class="to-uid">
  36. 赠送对象UID:
  37. </view>
  38. <input type="number" v-model="toUid" placeholder="请输入赠送对象UID">
  39. </view>
  40. <view class="zs-btns">
  41. <view class="zs-btn" @click="closeZs">
  42. 取消
  43. </view>
  44. <view class="zs-btn" style="color: #ff567f;" @click="giveGreen()">
  45. 赠送
  46. </view>
  47. </view>
  48. </view>
  49. </uni-popup>
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. getGreenCardList,
  55. giveGreen
  56. } from '@/api/user.js'
  57. import empty from '@/components/empty';
  58. export default {
  59. components: {
  60. empty
  61. },
  62. data() {
  63. return {
  64. zsItem: {},
  65. toUid: '',
  66. loaded: false,
  67. list: [],
  68. page: 1,
  69. limit: 10,
  70. loadingType: 'more'
  71. }
  72. },
  73. onLoad() {
  74. },
  75. onShow() {
  76. this.getGreenCardList()
  77. },
  78. onReachBottom() {
  79. this.getGreenCardList()
  80. },
  81. onReady() {
  82. },
  83. methods: {
  84. getGreenCardList() {
  85. let obj = this
  86. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  87. return
  88. }
  89. obj.loadingType = 'loading'
  90. getGreenCardList().then(res => {
  91. console.log(res)
  92. obj.list = obj.list.concat(res.data.data)
  93. obj.page++
  94. if (obj.limi == res.data.data.length) {
  95. obj.loadingType = 'more'
  96. } else {
  97. obj.loadingType = 'noMore'
  98. }
  99. obj.loaded = true
  100. })
  101. },
  102. giveGreen() {
  103. let obj = this
  104. console.log(obj.zsItem)
  105. if (obj.toUid == '') {
  106. return obj.$api.msg('请输入赠送对象UID')
  107. }
  108. giveGreen({
  109. id: obj.zsItem.id,
  110. uid: obj.toUid
  111. }).then(res => {
  112. this.closeZs()
  113. uni.showToast({
  114. title: '赠送成功',
  115. duration: 2000,
  116. position: 'top'
  117. });
  118. let s = obj.list.indexOf(obj.zsItem);
  119. obj.list.splice(s, 1);
  120. })
  121. },
  122. closeZs() {
  123. this.$refs.popup.close()
  124. },
  125. openZs(item) {
  126. this.zsItem = item
  127. this.$refs.popup.open()
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss">
  133. .green-card-wrap {
  134. width: 700rpx;
  135. height: 184rpx;
  136. margin: 0 auto 20rpx;
  137. position: relative;
  138. .card-bg {
  139. width: 700rpx;
  140. height: 184rpx;
  141. }
  142. .card-info {
  143. position: absolute;
  144. top: 0;
  145. left: 0;
  146. width: 700rpx;
  147. height: 184rpx;
  148. padding: 0 35rpx;
  149. .info-img {
  150. width: 112rpx;
  151. height: 112rpx;
  152. }
  153. .info-detail {
  154. flex-grow: 1;
  155. padding-left: 30rpx;
  156. color: #FFFFFF;
  157. font-size: 24rpx;
  158. font-weight: 500;
  159. .card-name {
  160. font-size: 36rpx;
  161. font-weight: bold;
  162. }
  163. .card-from {}
  164. .card-time {}
  165. }
  166. .card-btn-wrap {
  167. width: 132rpx;
  168. height: 100%;
  169. .card-btn {
  170. width: 132rpx;
  171. height: 53rpx;
  172. background: #FFFFFF;
  173. border-radius: 27rpx;
  174. font-size: 26rpx;
  175. font-weight: 500;
  176. text-align: center;
  177. line-height: 53rpx;
  178. color: #ff567f;
  179. }
  180. }
  181. }
  182. }
  183. .zs-wrap {
  184. width: 600rpx;
  185. height: 300rpx;
  186. background-color: #fff;
  187. border-radius: 20rpx;
  188. text-align: center;
  189. position: relative;
  190. .zs-tit {
  191. font-size: 32rpx;
  192. font-weight: bold;
  193. padding: 40rpx 0 50rpx;
  194. }
  195. .zs-uid {
  196. font-size: 28rpx;
  197. padding: 0 40rpx;
  198. .to-uid {
  199. flex-shrink: 0;
  200. }
  201. }
  202. .zs-btns {
  203. width: 100%;
  204. display: flex;
  205. position: absolute;
  206. bottom: 0;
  207. height: 80rpx;
  208. font-size: 32rpx;
  209. line-height: 80rpx;
  210. .zs-btn {
  211. width: 50%;
  212. }
  213. }
  214. }
  215. </style>