prizeList.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="prizeList">
  3. <zs-list class="store-box" mt="0" @load="prizeList" :status="status">
  4. <view class="item" v-for="(item,index) in list" :key="index">
  5. <zs-img :src="item.prizeIcon" width="160rpx" height="160rpx" mode=""></zs-img>
  6. <view class="info">
  7. <view class="title">
  8. {{item.prizeName}}
  9. </view>
  10. <view class="time">
  11. 中奖时间:{{item.createTime}}
  12. </view>
  13. <view class="valid">
  14. 有效期:中奖在{{item.valid}}天内领取,过期失效
  15. </view>
  16. <view class="desc">
  17. 奖品说明:{{item.prizeMsg||'无'}}
  18. </view>
  19. </view>
  20. <view class="btn-box">
  21. <view class="btn" :class="[(item.expire == 2 || item.status == 2)?'disable':'']" @click="handleBtn(item)">
  22. {{item | filterStatus}}
  23. </view>
  24. <view class="type">
  25. {{item.sendType |filterType}}
  26. </view>
  27. </view>
  28. </view>
  29. </zs-list>
  30. <!-- 视频会员 -->
  31. <zs-luck-dialog v-if="show" btnText="立即充值" @submit="submit" @close="handleClose('show')">
  32. <view class="result-box">
  33. <view class="goods-name">
  34. {{prizeInfo.prizeName}}
  35. </view>
  36. <image class="img" :src="prizeInfo.prizeImg" mode=""></image>
  37. <view class="input-box">
  38. <view class="label">
  39. 请输入充值手机号:
  40. </view>
  41. <input class="input" type="text" :maxlength="11" v-model.trim="account" placeholder="请输入充值账号" />
  42. </view>
  43. <view class="notice">
  44. 请立即输入账号进行充值,若不充值则视为放弃
  45. </view>
  46. </view>
  47. </zs-luck-dialog>
  48. <!-- 邮寄 -->
  49. <zs-luck-dialog v-if="show1" btnText="提交收货信息" @submit="submit1" @close="handleClose('show1')">
  50. <view class="result-box">
  51. <view class="goods-name">
  52. {{prizeInfo.prizeName}}
  53. </view>
  54. <image class="img" :src="prizeInfo.prizeImg" mode=""></image>
  55. <view class="sub-title">
  56. 中奖奖品将邮寄给您,请输入收货信息
  57. </view>
  58. <u--form :model="noteQuery" ref="uForm" borderBottom labelWidth="180rpx" :labelStyle="{'color': '#222222','font-weight': 'bold','line-height':'60rpx','font-size': '28rpx'}">
  59. <u-form-item label="收货人姓名" prop="notes.name" borderBottom ref="item1" required>
  60. <u--input v-model.trim="noteQuery.notes.name" placeholder="请输入姓名" border="none"></u--input>
  61. </u-form-item>
  62. <u-form-item label="收货地址" prop="notes.address" borderBottom ref="item1" required>
  63. <u--input v-model.trim="noteQuery.notes.address" :maxlength="50" placeholder="请输入收货地址" border="none"></u--input>
  64. </u-form-item>
  65. <u-form-item label="联系电话" prop="notes.phone" borderBottom ref="item1" required>
  66. <u--input v-model.trim="noteQuery.notes.phone" :maxlength="11" placeholder="请输入手机号" border="none"></u--input>
  67. </u-form-item>
  68. </u--form>
  69. <view class="notice">
  70. 说明:为保障商品及时送到您的手中,请填写准确的地
  71. 址信息,若提交后需要修改地址信息请及时联系客服
  72. </view>
  73. </view>
  74. </zs-luck-dialog>
  75. <!-- 线上发货 线下自提 -->
  76. <zs-luck-dialog v-if="show2" @submit="handleClose('show2')" @close="handleClose('show2')">
  77. <view class="result-box">
  78. <view class="goods-name">
  79. {{prizeInfo.prizeName}}
  80. </view>
  81. <image class="img" :src="prizeInfo.prizeImg" mode=""></image>
  82. <view class="address">
  83. 取货地址:{{prizeInfo.address}}
  84. </view>
  85. <view class="notice">
  86. {{prizeInfo.sendType == 1?`兑换有效期:请在${prizeInfo.valid}个工作日内到自提点取货,过期失效`:'优惠劵已存入【我的优惠劵】,可前往【我的优惠劵】中查看使用'}}
  87. </view>
  88. </view>
  89. </zs-luck-dialog>
  90. </view>
  91. </template>
  92. <script>
  93. import {
  94. prizeList,sendVipPrize,notes
  95. } from "@/api/luckyDraw.js"
  96. export default {
  97. data() {
  98. return {
  99. status:'more',
  100. prizeInfo:{},
  101. account:'',
  102. show:false,
  103. show1:false,
  104. show2:false,
  105. list: [],
  106. query:{
  107. raffleId:0,
  108. currentPage:1,
  109. pageSize:10,
  110. phoneNum:JSON.parse(uni.getStorageSync('userInfo')).phoneNum
  111. },
  112. userId:JSON.parse(uni.getStorageSync('userInfo')).userId,
  113. noteQuery:{
  114. "notes": {
  115. "address": "",
  116. "name": "",
  117. "phone": ""
  118. },
  119. "rafflePrizeLogId": 0
  120. },
  121. rules:{
  122. 'notes.name': {
  123. type: 'string',
  124. required: true,
  125. message: '请输入姓名',
  126. trigger: ['blur', 'change']
  127. },
  128. 'notes.address': {
  129. type: 'string',
  130. required: true,
  131. message: '请输入收货地址',
  132. trigger: ['blur', 'change']
  133. },
  134. 'notes.phone': {
  135. type: 'string',
  136. required: true,
  137. message: '请输入手机号',
  138. trigger: ['blur', 'change']
  139. },
  140. }
  141. }
  142. },
  143. filters: {
  144. filterType: function(value) {
  145. if(value == 1){
  146. return '线下自提'
  147. }else if(value == 2){
  148. return '邮寄发货'
  149. }else if(value == 3){
  150. return '线上发货'
  151. }
  152. },
  153. filterStatus(val){
  154. if(val.expire == 2){
  155. return '已过期'
  156. }else if(val.status == 1){
  157. return '未领取'
  158. }else if(val.status == 2){
  159. return '已领取'
  160. }
  161. }
  162. },
  163. methods: {
  164. handleBtn(item){
  165. if(item.expire == 2 || item.status == 2){//已过期 或者已领取
  166. return
  167. }
  168. if(item.prizeType == 2){//视频会员
  169. this.show = true
  170. }else if(item.sendType == 2){//邮寄
  171. this.show1 = true
  172. this.$nextTick(() => {
  173. this.$refs.uForm.setRules(this.rules)
  174. })
  175. }else{//线上发货 线下自提
  176. this.show2 = true
  177. }
  178. this.prizeInfo = item
  179. this.account = this.query.phoneNum
  180. },
  181. handleClose(key){
  182. this[key] = false
  183. },
  184. // 视频会员领取
  185. submit(){
  186. if(!this.account){
  187. return uni.showToast({
  188. title:'请输入账号',
  189. icon:'none'
  190. })
  191. }else if(!uni.$u.test.mobile(this.account)){
  192. return uni.showToast({
  193. title:'手机号错误',
  194. icon:'none'
  195. })
  196. }else{
  197. uni.showLoading({
  198. title:'提交中'
  199. })
  200. sendVipPrize({accountType:1,mobile:this.account,productId:this.prizeInfo.prizeContent,userId:this.userId,rafflePrizeLogId:this.prizeInfo.rafflePrizeLogId,rafflePrizeId:this.prizeInfo.rafflePrizeId}).then(res=>{
  201. if (res.state == 'Success') {
  202. uni.hideLoading({noConflict:true})
  203. this.show1 = false
  204. this.init()
  205. this.account = this.query.phoneNum
  206. uni.showToast({
  207. title:'领取成功',
  208. icon:'none'
  209. })
  210. }
  211. })
  212. }
  213. },
  214. // 邮寄信息
  215. submit1(){
  216. this.$refs.uForm.validate().then(res => {
  217. uni.showLoading({
  218. title:'提交中'
  219. })
  220. this.noteQuery.rafflePrizeLogId = this.prizeInfo.rafflePrizeLogId
  221. notes(this.noteQuery).then(res=>{
  222. if (res.state == 'Success') {
  223. this.show1 = false
  224. uni.hideLoading({noConflict:true})
  225. this.init()
  226. uni.showToast({
  227. title:'提交成功',
  228. icon:'none'
  229. })
  230. }
  231. })
  232. })
  233. },
  234. prizeList(){
  235. this.status = 'loading'
  236. prizeList(this.query).then(res=>{
  237. if (res.state == 'Success') {
  238. this.list = this.list.concat(res.content.records)
  239. if(this.list.length>= res.content.total){
  240. this.status = 'noMore'
  241. }else{
  242. this.status = 'more'
  243. this.query.currentPage++
  244. }
  245. }
  246. })
  247. },
  248. init(){
  249. this.query.currentPage = 1
  250. this.list = []
  251. this.status = 'more'
  252. this.prizeList()
  253. }
  254. },
  255. onLoad(options) {
  256. this.query.raffleId = options.id
  257. try{
  258. this.query.phoneNum=JSON.parse(uni.getStorageSync('userInfo')).phoneNum
  259. }catch(e){
  260. //TODO handle the exception
  261. return uni.showModal({
  262. title:'请登录',
  263. confirmText:'去登录',
  264. success(res){
  265. console.log(res);
  266. if(res.confirm){
  267. uni.navigateTo({
  268. url:'../../login/login/login?redirect=/luckyDraw/prizeList'
  269. })
  270. }
  271. }
  272. })
  273. }
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .prizeList{
  279. padding: 20rpx 24rpx ;
  280. background: #F9F9F9;
  281. min-height: 100vh;
  282. .item{
  283. display: flex;
  284. padding: 28rpx 24rpx;
  285. background: #FFFFFF;
  286. border-radius: 16rpx 16rpx 16rpx 16rpx;
  287. margin-bottom: 20rpx;
  288. .info{
  289. padding-left: 20rpx;
  290. flex: 1;
  291. display: flex;
  292. flex-direction: column;
  293. justify-content: space-between;
  294. .title{
  295. font-weight: bold;
  296. font-size: 28rpx;
  297. color: #222222;
  298. }
  299. .time{
  300. font-size: 20rpx;
  301. color: #AAAAAA;
  302. }
  303. .valid{
  304. font-size: 20rpx;
  305. color: #AAAAAA;
  306. }
  307. .desc{
  308. font-size: 20rpx;
  309. color: #AAAAAA;
  310. }
  311. }
  312. .btn-box{
  313. width: 120rpx;
  314. text-align: center;
  315. .btn{
  316. width: 120rpx;
  317. height: 48rpx;
  318. line-height: 48rpx;
  319. background: #EE4320;
  320. border-radius: 28rpx 28rpx 28rpx 28rpx;
  321. font-size: 24rpx;
  322. color: #FFFFFF;
  323. text-align: center;
  324. }
  325. .btn.disable{
  326. background: #F0F0F0;
  327. color: #AAAAAA;
  328. }
  329. .type{
  330. font-size: 24rpx;
  331. color: #3B83FF;
  332. margin-top: 20rpx;
  333. }
  334. }
  335. }
  336. .result-box{
  337. width: 90%;
  338. text-align: center;
  339. margin: 0 auto;
  340. padding-bottom: 200rpx;
  341. .goods-name{
  342. font-weight: bold;
  343. font-size: 28rpx;
  344. color: #222222;
  345. }
  346. .img{
  347. width: 168rpx;
  348. height: 168rpx;
  349. margin-top: 20rpx;
  350. }
  351. .sub-title{
  352. font-size: 24rpx;
  353. color: #222222;
  354. margin-top: 20rpx;
  355. }
  356. .input-box{
  357. display: flex;
  358. font-size: 28rpx;
  359. color: #222222;
  360. margin-top: 20rpx;
  361. .label{
  362. font-weight: bold;
  363. font-size: 28rpx;
  364. color: #222222;
  365. width: 350rpx;
  366. white-space: nowrap;
  367. }
  368. .input{
  369. font-size: 28rpx;
  370. color: #222222;
  371. }
  372. }
  373. .address{
  374. font-weight: bold;
  375. font-size: 28rpx;
  376. color: #222222;
  377. margin-top: 20rpx;
  378. }
  379. .notice{
  380. font-size: 20rpx;
  381. color: #AAAAAA;
  382. margin-top: 20rpx;
  383. }
  384. }
  385. }
  386. </style>