index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <view>
  3. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的奖品库"></u-navbar>
  4. <!-- 奖品选择 -->
  5. <view class="prize-state">
  6. <u-tabs @change="changeTab" :scrollable="false" :list="stateArr" lineWidth="40" lineHeight="1"
  7. lineColor="#D70909" :activeStyle="{
  8. color: '#D70909',
  9. transform: 'scale(1)'
  10. }" :inactiveStyle="{
  11. color: '#333',
  12. transform: 'scale(1)'
  13. }" itemStyle="padding-left: 25px; padding-right: 25px; height: 44px;">
  14. </u-tabs>
  15. </view>
  16. <!-- 实物商品 -->
  17. <view class="prize-goods" v-if="state == 0">
  18. <view class="prize-goods-list">
  19. <view class="flex prize-goods-list-item" v-for="(item, index) in list" :key="index">
  20. <view class="flex checkbox">
  21. <u-checkbox-group>
  22. <u-checkbox size="24" :value="item.checked" shape="circle" :checked="item.checked"
  23. activeColor="#E96737" @change="changeChecked($event, item)"></u-checkbox>
  24. </u-checkbox-group>
  25. </view>
  26. <view class="flex info">
  27. <image :src="item.picUrl" mode="aspectFill"></image>
  28. <view class="flex desc">
  29. <view class="ells content">{{ item.title }}</view>
  30. <view class="sku" v-if="item.properties">规格:{{ item.properties }}</view>
  31. <view class="">数量:{{ item.goodsNum }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="flex empty" v-if="!list.length && !loading">
  37. <u-empty text="数据为空" mode="order" />
  38. </view>
  39. </view>
  40. <!-- 卡券 -->
  41. <view class="prize-coupon" v-else>
  42. <view class="prize-coupon-list">
  43. <!-- <navigator :url="`/pages/prize/detail?info=${ JSON.stringify(item) }`" class="flex prize-coupon-list-item" hover-class="navigator-hover" v-for="(item, index) in list" :key="index">
  44. <image :src="item.picUrl" mode="aspectFill"></image>
  45. <view class="flex info">
  46. <view class="flex desc">
  47. <view class="title">{{ item.title }}</view>
  48. <view class="txt">使用期限:{{ $parseTime(item.validStart, '{y}.{m}.{d}') }}-{{ $parseTime(item.validEnd, '{y}.{m}.{d}') }}</view>
  49. <view class="txt">使用范围:{{ item.useAreaDesc }}</view>
  50. </view>
  51. <view class="flex btn">
  52. <view class="amt"><text>¥</text>{{ item.discount / 100 }}</view>
  53. <view class="action">立即使用</view>
  54. </view>
  55. </view>
  56. </navigator> -->
  57. <navigator :url="`/pages/prize/detail?info=${ JSON.stringify(item) }`" class="prize-coupon-list-item"
  58. hover-class="navigator-hover" v-for="(item, index) in list" :key="index">
  59. <image src="../../static/icon/coupon_bg.png" mode=""></image>
  60. <view class="info">
  61. <view class="info-item">
  62. <text>使用期限:</text>
  63. <text>{{ $parseTime(item.validStart, '{y}.{m}.{d}') }}-{{ $parseTime(item.validEnd, '{y}.{m}.{d}') }}</text>
  64. </view>
  65. <view class="info-item">
  66. <text>使用范围:</text>
  67. <text>{{ item.useAreaDesc || '-' }}</text>
  68. </view>
  69. </view>
  70. <view class="flex price-title">
  71. <view class="price"><text>¥</text>{{ item.discount / 100 }}</view>
  72. <view class="title">{{ item.title }}</view>
  73. </view>
  74. </navigator>
  75. </view>
  76. <view class="flex empty" v-if="!list.length && !loading">
  77. <u-empty text="数据为空" mode="order" />
  78. </view>
  79. </view>
  80. <view class="prize-action">
  81. <!-- 实物商品提货 -->
  82. <view class="flex prize-action-goods" v-if="state == 0">
  83. <view class="flex checkbox">
  84. <view class="all">全选</view>
  85. <u-checkbox-group>
  86. <u-checkbox v-model="checkedAll" shape="circle" size="24" :checked="checkedAll"
  87. activeColor="#E96737" @change="changeCheckedAll($event)"></u-checkbox>
  88. </u-checkbox-group>
  89. </view>
  90. <view class="btn" @click="toSettlement">立即提货</view>
  91. </view>
  92. <!-- 卡券使用记录 -->
  93. <view class="flex prize-action-coupon" @click="toCoupon" v-else>
  94. <view class="title">卡券使用记录</view>
  95. <u-icon name="arrow-right" size="15" color="#333"></u-icon>
  96. </view>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import env from '../../config/env.js'
  102. import $http from '@/utils/request.js'
  103. export default {
  104. data() {
  105. return {
  106. loading: false,
  107. stateArr: [{
  108. name: '实物商品'
  109. }, {
  110. name: '卡券',
  111. }],
  112. state: 0,
  113. checkedAll: false,
  114. pageNum: 1,
  115. total: 0,
  116. list: [],
  117. };
  118. },
  119. onShow() {
  120. this.pageList()
  121. },
  122. methods: {
  123. getList() {
  124. let _this = this
  125. let url = _this.state == 0 ? '/api/v1/mp/user/mine/prize/list' : '/api/v1/mp/user/mine/coupon/list'
  126. let data = _this.state == 0 ? {} : {
  127. status: 1
  128. }
  129. uni.showLoading({
  130. title: '加载中'
  131. });
  132. this.loading = true
  133. this.checkedAll = false
  134. $http.post(`${ url }?pageNum=${_this.pageNum}&pageSize=20`, data).then(res => {
  135. uni.hideLoading();
  136. this.loading = false
  137. if (res.code == 0) {
  138. res.rows.forEach(item => {
  139. let picUrlArr = item.picUrl.split(',')
  140. item.picUrl = env.filePublic + picUrlArr[0]
  141. if (_this.state == 0) {
  142. item.checked = false
  143. }
  144. })
  145. _this.total = res.total
  146. _this.list = _this.list.concat(res.rows)
  147. }
  148. }).catch(() => {
  149. uni.hideLoading();
  150. this.loading = false
  151. })
  152. },
  153. pageList() {
  154. this.pageNum = 1
  155. this.list = []
  156. this.getList()
  157. },
  158. // 切换奖品
  159. changeTab(e) {
  160. if (e.index == 0) {
  161. this.state = 0
  162. } else if (e.index == 1) {
  163. this.state = 1
  164. }
  165. this.pageList()
  166. this.checkedAll = false
  167. },
  168. changeChecked(e, item) {
  169. this.$set(item, 'checked', e)
  170. let flag = this.list.every(item => item.checked == true)
  171. this.checkedAll = flag
  172. this.$forceUpdate()
  173. },
  174. changeCheckedAll(e) {
  175. this.checkedAll = e
  176. this.list.forEach(item => {
  177. item.checked = e
  178. })
  179. this.$forceUpdate()
  180. },
  181. // 查看卡券使用记录
  182. toCoupon() {
  183. uni.navigateTo({
  184. url: '/pages/prize/coupon'
  185. })
  186. },
  187. // 立即提货
  188. toSettlement() {
  189. let arr = []
  190. this.list.forEach(item => {
  191. if (item.checked) {
  192. arr.push(item)
  193. }
  194. })
  195. if (!arr.length) {
  196. uni.$u.toast('请选择商品');
  197. return
  198. }
  199. uni.showLoading({
  200. title: '提货中'
  201. });
  202. let ids = JSON.stringify(arr.map(item => item.storageId))
  203. uni.hideLoading();
  204. uni.navigateTo({
  205. url: `/pages/order/settlement?ids=${ ids }`
  206. })
  207. },
  208. },
  209. onReachBottom() {
  210. // 判断是否有数据
  211. if (this.total > this.pageNum * 20) {
  212. setTimeout(() => {
  213. ++this.pageNum
  214. this.getList()
  215. }, 500)
  216. } else {
  217. uni.$u.toast('没有更多数据了')
  218. }
  219. },
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .empty {
  224. height: 60vh;
  225. }
  226. .prize-state {
  227. position: fixed;
  228. background-color: #FFFFFF;
  229. width: 100%;
  230. padding-bottom: 16rpx;
  231. z-index: 10;
  232. box-shadow: 0 5rpx 5rpx #ececec;
  233. }
  234. .prize-goods {
  235. margin-top: 90rpx;
  236. padding: 40rpx 20rpx 200rpx;
  237. &-list {
  238. &-item {
  239. justify-content: space-between;
  240. padding: 36rpx 16rpx;
  241. background-color: #fff;
  242. border-radius: 10rpx;
  243. margin-bottom: 30rpx;
  244. .checkbox {}
  245. .info {
  246. flex: 1;
  247. justify-content: flex-start;
  248. }
  249. image {
  250. width: 200rpx;
  251. height: 200rpx;
  252. }
  253. .desc {
  254. height: 200rpx;
  255. padding-left: 22rpx;
  256. flex: 1;
  257. font-size: 30rpx;
  258. flex-direction: column;
  259. align-items: flex-start;
  260. justify-content: space-between;
  261. }
  262. .content {
  263. line-height: 40rpx;
  264. font-weight: bold;
  265. }
  266. .sku {
  267. color: #848484;
  268. }
  269. .num {
  270. width: 100%;
  271. color: #8C8C8C;
  272. justify-content: space-between;
  273. }
  274. }
  275. &-item:last-child {
  276. margin-bottom: 0;
  277. }
  278. }
  279. }
  280. .prize-coupon {
  281. margin-top: 90rpx;
  282. padding: 40rpx 20rpx 150rpx;
  283. &-list {
  284. &-item {
  285. position: relative;
  286. background-color: #FFFFFF;
  287. margin-bottom: 20rpx;
  288. border-radius: 10rpx;
  289. image {
  290. width: 100%;
  291. height: 156rpx;
  292. margin-bottom: 24rpx;
  293. }
  294. .info {
  295. padding-left: 40rpx;
  296. padding-bottom: 8rpx;
  297. .info-item {
  298. line-height: 40rpx;
  299. color: #333333;
  300. margin-bottom: 12rpx;
  301. }
  302. }
  303. .price-title {
  304. justify-content: flex-start;
  305. position: absolute;
  306. top: 0;
  307. width: 100%;
  308. padding: 36rpx 0 0 40rpx;
  309. .price {
  310. color: #FFFFFF;
  311. font-size: 60rpx;
  312. margin-right: 20rpx;
  313. text {
  314. font-size: 40rpx;
  315. }
  316. }
  317. .title {
  318. color: #FFFFFF;
  319. font-size: 48rpx;
  320. }
  321. }
  322. }
  323. &-item:last-child {
  324. margin-bottom: 0;
  325. }
  326. }
  327. }
  328. .prize-action {
  329. position: fixed;
  330. bottom: var(--window-bottom);
  331. left: 0;
  332. right: 0;
  333. z-index: 10;
  334. box-shadow: 0 -4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  335. background: #fff;
  336. width: 100%;
  337. // 设置ios刘海屏底部横线安全区域
  338. padding-bottom: constant(safe-area-inset-bottom);
  339. padding-bottom: env(safe-area-inset-bottom);
  340. &-goods {
  341. justify-content: space-between;
  342. padding: 20rpx 40rpx;
  343. .all {
  344. margin-right: 10rpx;
  345. }
  346. .btn {
  347. width: 280rpx;
  348. height: 90rpx;
  349. font-size: 36rpx;
  350. line-height: 90rpx;
  351. border-radius: 10rpx;
  352. background-color: rgba(235, 112, 9, 100);
  353. color: rgba(255, 255, 255, 100);
  354. text-align: center;
  355. }
  356. }
  357. &-coupon {
  358. padding: 30rpx 40rpx;
  359. .title {
  360. margin-right: 20rpx;
  361. line-height: 40rpx;
  362. }
  363. }
  364. }
  365. </style>