myGreenCard.vue 4.2 KB

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