myGift.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view>
  3. <u-sticky h5-nav-height="0">
  4. <u-tabs :list="list" active-color="#5c40e8" :is-scroll="false" :current="current" @change="change"></u-tabs>
  5. </u-sticky>
  6. <view v-if="current == 0">
  7. <block v-if="!$u.test.isEmpty(giftList)">
  8. <block v-for="(item, index) in giftList" :key="index">
  9. <view class="card" @click="select(item)">
  10. <view class="flex">
  11. <view :class="item.selected==true ? 'theme-color cuIcon-roundcheckfill':'cuIcon-round'" class="padding-sm" style="font-size: 50upx;"></view>
  12. <view class="padding-tb-sm">
  13. <view class="flex margin-top-xs">
  14. <image :src="item.goods.goodsPic" style="width: 220upx;height: 220upx;border-radius: 10rpx;"></image>
  15. <view class="padding-left-sm">
  16. <view class="name text-cut" style="width: 350upx;">{{item.goods.goodsName}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="flex justify-end padding" style="margin-top: -110upx;">
  22. <view class="count" style="border: #d9d9d9 1upx solid;" v-if="!item.selected">x{{item.exCount}}</view>
  23. <view class="justify-center flex align-center" v-else>
  24. <view class="" @click.stop="minus(item)"> <u-icon name="minus-circle-fill" color="#5a3ee8" size="36"></u-icon> </view>
  25. <input type="number" class="text-center input" v-model="item.exCount" />
  26. <view class="" @click.stop="plus(item)"> <u-icon name="plus-circle-fill" color="#5a3ee8" size="36"></u-icon> </view>
  27. </view>
  28. </view>
  29. </view>
  30. </block>
  31. <view style="height: 120upx;"></view>
  32. <view style="z-index: 9;" class="footer-fixed flex align-center justify-between padding-sm bg-white">
  33. <view class="flex align-center" @click="selectAll">
  34. <view :class="selectAllShow ? 'theme-color cuIcon-roundcheckfill':'cuIcon-round'" class="padding-right-xs" style="font-size: 50upx;"></view>
  35. <view class="text-sm padding-right-xs">全选</view>
  36. </view>
  37. <view>
  38. <button class="cu-btn round text-white theme-bg-color" style="width: 180upx;height: 80upx;margin-right: 30upx;" @click="donate">捐赠</button>
  39. <button class="cu-btn round text-white theme-bg-color" style="width: 180upx;height: 80upx;" @click="navTap">领取</button>
  40. </view>
  41. </view>
  42. </block>
  43. <u-empty v-else margin-top="300" text="暂无礼物" mode="list"></u-empty>
  44. </view>
  45. <view v-if="current == 2">
  46. <block v-for="(item, index) in giftList" :key="index">
  47. <view class="card" v-if="item.status == '已完成'">
  48. <view class="padding">
  49. <view class="flex justify-between align-center padding-bottom-sm">
  50. <view class="flex align-center">
  51. <view class="cuIcon-goods padding-right-xs text-bold text-black" style="font-size: 40upx;"></view>
  52. <view class="title">{{item.title}}</view>
  53. </view>
  54. <view>
  55. <text class="padding-right-sm text-gray">已完成</text>
  56. <text class="cuIcon-delete text-gray" style="font-size: 30upx;"></text>
  57. </view>
  58. </view>
  59. <view class="flex margin-top-xs">
  60. <image :src="item.image" style="width: 220upx;height: 220upx"></image>
  61. <view class="padding-left-sm">
  62. <view class="name text-cut" style="width: 350upx;">{{item.name}}</view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="flex justify-end padding" style="margin-top: -120upx;">
  67. <view class="count">x{{item.count}}</view>
  68. </view>
  69. </view>
  70. </block>
  71. </view>
  72. <u-popup v-model="dialogShow" mode="center" width="500" height="480" border-radius="30">
  73. <view class="bg-img text-center" style="background-image: url('/static/dialogBgImg.png');height: 600rpx;">
  74. <view style="height: 80upx;"></view>
  75. <view style="font-size: 50upx;font-family: PingFang SC;font-weight: 600;color: #ffffff;">感谢你</view>
  76. <view class="text-bold text-black" style="padding: 80upx 0;">广发基金会已收到您的捐赠!</view>
  77. <view class="padding">
  78. <u-button class="custom-style" shape="circle" @click="confirm">确定</u-button>
  79. </view>
  80. </view>
  81. </u-popup>
  82. </view>
  83. </template>
  84. <script>
  85. export default {
  86. data() {
  87. return {
  88. userId:"2",
  89. successList:[],
  90. list: [{
  91. name: '待领取'
  92. }, {
  93. name: '配送中'
  94. }, {
  95. name: '已完成'
  96. }],
  97. current: 0,
  98. selectAllShow: false,
  99. clickShow: false,
  100. giftList: [],
  101. dialogShow: false,
  102. }
  103. },
  104. onLoad() {
  105. this.getMineGiftList()
  106. },
  107. methods: {
  108. getMineGiftList(){
  109. this.$u.api.goods.getMineGoods({userId:this.userId}).then(res=>{
  110. this.giftList=res.records
  111. this.giftList.forEach(item=>{
  112. item.selected=false
  113. item.exCount=item.count
  114. })
  115. })
  116. },
  117. change(index) {
  118. this.current = index;
  119. },
  120. select(item) {
  121. item.selected=!item.selected
  122. let flag = true;
  123. for (let item of this.giftList) {
  124. if (!item.selected) {
  125. flag = false;
  126. }
  127. }
  128. this.selectAllShow = flag;
  129. this.$forceUpdate()
  130. },
  131. selectAll() {
  132. this.selectAllShow = !this.selectAllShow;
  133. for (let item of this.giftList) {
  134. if (this.selectAllShow) {
  135. item.selected = true;
  136. } else {
  137. item.selected = false;
  138. }
  139. }
  140. },
  141. donate() {
  142. let flag=false
  143. this.giftList.forEach(item=>{
  144. if (item.selected) {
  145. flag=true
  146. }
  147. })
  148. if (!flag) {
  149. uni.showToast({
  150. title:"请至少选择一个礼物!",
  151. icon:"none"
  152. })
  153. return
  154. }
  155. let newList=this.getSelectGoods()
  156. this.$dialog.showModal("确认捐赠?").then(()=>{
  157. this.$u.api.goods.donate(newList).then(res=>{
  158. // this.successList=res.records
  159. this.dialogShow=true
  160. })
  161. })
  162. },
  163. getSelectGoods(){
  164. let newList=[]
  165. this.giftList.forEach(item=>{
  166. let obj={
  167. id:item.id,
  168. userId:item.userId,
  169. goodsId:item.goodsId,
  170. activityIds:item.activityIds,
  171. count:item.exCount
  172. }
  173. newList.push(obj)
  174. })
  175. return newList
  176. },
  177. confirm(){
  178. this.dialogShow = false;
  179. this.getMineGiftList()
  180. },
  181. navTap() {
  182. let newList=[]
  183. this.giftList.forEach(item=>{
  184. let obj={
  185. id:item.id,
  186. userId:item.userId,
  187. goodsId:item.goodsId,
  188. activityIds:item.activityIds,
  189. count:item.exCount,
  190. goodsPic:item.goods.goodsPic,
  191. goodsName:item.goods.goodsName,
  192. donateMedalId:item.goods.donateMedalId
  193. }
  194. newList.push(obj)
  195. })
  196. let params=JSON.stringify(newList)
  197. uni.navigateTo({
  198. url: '/pages/activityList/mine/order/orderConfirm?goods='+params
  199. })
  200. },
  201. //礼物+
  202. plus(item) {
  203. if (item.exCount<item.count) {
  204. item.exCount++
  205. }
  206. this.$forceUpdate()
  207. },
  208. //礼物 -
  209. minus(item) {
  210. if (item.exCount>1) {
  211. item.exCount--
  212. }
  213. this.$forceUpdate()
  214. },
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .card {
  220. margin: 20upx;
  221. border-radius: 16upx;
  222. background-color: #FFFFFF;
  223. .title {
  224. font-size: 28upx;
  225. font-family: PingFang SC;
  226. font-weight: 800;
  227. color: #222222;
  228. }
  229. .name {
  230. font-size: 26upx;
  231. font-family: PingFang SC;
  232. font-weight: 800;
  233. color: #222222;
  234. }
  235. .specification {
  236. padding-top: 30upx;
  237. font-size: 24upx;
  238. font-family: PingFang SC;
  239. font-weight: bold;
  240. color: #959595;
  241. }
  242. .count {
  243. width: 60upx;
  244. height: 60upx;
  245. border-radius: 16upx;
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. }
  250. }
  251. .input {
  252. width: 80upx;
  253. background-color: #ffffff;
  254. text-align: center;
  255. border: none;
  256. height: 60rpx;
  257. min-height: 1.8rem;
  258. }
  259. .custom-style {
  260. background-color: #5b3ee7;
  261. width: 250upx;
  262. color: #ffffff;
  263. }
  264. </style>