myJp.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <view class="page-cont">
  3. <view class="list" v-for="(item,index) in list" :key="item.id">
  4. <view class="no">奖品{{index+1}}</view>
  5. <view class="names">{{item.prizeDesc}}</view>
  6. <view class="lingjiang" v-if="item.state == 'WAIT_RECEIVE'" @click="lingjiang(item)">领奖</view>
  7. <view class="viewsDetail" v-else @click="viewsDetail(item)">查看详情</view>
  8. </view>
  9. <view style="padding:150rpx 30rpx 0;" v-if="list.length == 0">
  10. <u-empty text="还没有奖品记录" :icon-size="80" mode="list"></u-empty>
  11. <!-- <view style="text-align: center;">
  12. <u-button size="mini" @click="goBack">去抽奖</u-button>
  13. </view> -->
  14. </view>
  15. <!-- 查看详情弹框 -->
  16. <u-popup v-model="showViews" mode="center" close-icon-color="#ffffff" closeable :border-radius="30" width="500rpx">
  17. <view class="lottery-content">
  18. <view class="lottery-title">物流信息</view>
  19. <view class="lottery-form">
  20. <view>
  21. <view class="labes">收件人</view>
  22. <view>{{curRevice.receiverName}}</view>
  23. </view>
  24. <view>
  25. <view class="labes">联系电话</view>
  26. <view>{{curRevice.receiverPhone}}</view>
  27. </view>
  28. <view>
  29. <view class="labes">收货地址</view>
  30. <view style="word-break: break-all;">{{curRevice.receiveAddress}}</view>
  31. </view>
  32. <view>
  33. <view class="labes">物流单号</view>
  34. <view>
  35. <view v-if="curRevice.state == 'WAIT_SEND_EXPRESS'">暂未发货,如收货信息有误, 请联系客服电话<text class="tell" @click="callPhone">{{kfPhone}}</text></view>
  36. <view v-else>
  37. {{curRevice.expressName}} <text class="tell">(单号:{{curRevice.expressNum}})</text> <u-button @click="copyWlCode" size="mini">复制</u-button>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view @click="showViews=false" class="lottery-confrim-btn">
  43. 确定
  44. </view>
  45. </view>
  46. </u-popup>
  47. <!-- 乐豆领取详情弹框 -->
  48. <u-popup v-model="showLjLd" mode="center" close-icon-color="#ffffff" closeable :border-radius="30" width="500rpx">
  49. <view class="lottery-content">
  50. <view class="lottery-title">欢迎领取</view>
  51. <view class="lottery-msg">
  52. 您的奖励已计入乐豆余额,感谢参与!
  53. </view>
  54. <view @click="showLjLd=false" class="lottery-confrim-btn">
  55. 我知道了
  56. </view>
  57. </view>
  58. </u-popup>
  59. <!-- 收货地址详情弹框 -->
  60. <u-popup v-model="showAddr" mode="center" close-icon-color="#ffffff" closeable :border-radius="30" width="80%">
  61. <view class="lottery-content">
  62. <view class="lottery-title">收货信息</view>
  63. <view class="lottery-u-form">
  64. <u-form :model="form" ref="uForm" :label-width="140" :error-type="['toast']">
  65. <u-form-item label="收货人" required prop="receiverName">
  66. <u-input placeholder="请输入收货人姓名" :maxlength="30" v-model="form.receiverName" />
  67. </u-form-item>
  68. <u-form-item label="收货电话" required prop="receiverPhone">
  69. <u-input placeholder="请输入收货电话" :maxlength="11" type="number" v-model="form.receiverPhone" />
  70. </u-form-item>
  71. <u-form-item label="省市区" required prop="receiveAreasName">
  72. <u-input v-model="areaInfo.label" placeholder="请选择省市区" @click="openAddress" type="select" />
  73. <Address ref="applyAddress" @onConfirm="areaConfirm"></Address>
  74. </u-form-item>
  75. <u-form-item label="详细地址" :border-bottom="false" required prop="receiveAddress">
  76. <u-input type="textarea" :height="100" auto-height placeholder="请输入收货详细地址(最多100个字符)" :maxlength="100" v-model="form.receiveAddress" class="receiveAddress"/>
  77. </u-form-item>
  78. </u-form>
  79. </view>
  80. <view @click="wlSubmit" class="lottery-confrim-btn">
  81. 确定
  82. </view>
  83. </view>
  84. </u-popup>
  85. </view>
  86. </template>
  87. <script>
  88. import Address from '@/components/address.vue'
  89. import {findAddressBycustomerNo, saveAddress} from '@/api/receiveAddress.js'
  90. import { findWinPrize, receive } from '@/api/luckyDraw.js'
  91. export default {
  92. components: {
  93. Address
  94. },
  95. data() {
  96. return {
  97. kfPhone:'', // 客服电话
  98. showViews: false, // 查看详情弹框
  99. showAddr: false ,// 实物奖品,收货地址弹框
  100. showLjLd: false, // 虚拟奖品领奖弹框
  101. form: {
  102. receiverName: '',
  103. receiverPhone: '',
  104. receiveAddress: '' // 详细地址
  105. },
  106. receiveAreas: '', //地址编码
  107. areaName: '', //地址
  108. areaInfo: {}, // 省市区
  109. areaIdArr: [], // 省市区id数组
  110. list: [],
  111. curRevice: null,
  112. fromPage: ''
  113. }
  114. },
  115. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  116. onReady() {
  117. this.$refs.uForm.setRules(this.rules);
  118. },
  119. onLoad(option) {
  120. console.log(option,'option')
  121. this.getfindWinPrize()
  122. this.kfPhone = this.$store.state.vuex_kfMobile
  123. this.fromPage = option.fromPage
  124. },
  125. onUnload() {
  126. this.form = {
  127. receiverName: '',
  128. receiverPhone: '',
  129. receiveAddress: '' // 详细地址
  130. }
  131. },
  132. methods: {
  133. goBack(){
  134. if(this.fromPage == 'usercenter'){
  135. uni.redirectTo({
  136. url: '/pagesA/luckDraw/luckDraw'
  137. })
  138. }else{
  139. uni.navigateBack()
  140. }
  141. },
  142. // 电话客服
  143. callPhone () {
  144. uni.makePhoneCall({
  145. phoneNumber: this.kfPhone
  146. })
  147. },
  148. getfindWinPrize(){
  149. uni.showLoading({
  150. mask: true,
  151. title: '正在加载...'
  152. })
  153. findWinPrize().then(res => {
  154. if(res.status == 200){
  155. this.list = res.data
  156. }
  157. uni.hideLoading()
  158. })
  159. },
  160. // 获取用户收货地址
  161. getAddress() {
  162. findAddressBycustomerNo({}).then(res => {
  163. console.log(res)
  164. if (res.status == 200&&res.data.length) {
  165. this.form = res.data[0]
  166. if (this.form.receiveAreasName) {
  167. this.areaIdArr = this.form.receiveAreas.split(',')
  168. this.areaInfo.label = this.form.receiveAreasName.replace(/\,/g,'-')
  169. }
  170. this.$u.vuex("vuex_OrderAddress",this.form)
  171. }
  172. })
  173. },
  174. // 选择省区市
  175. areaConfirm(e) {
  176. console.log('已选择的省市区', e)
  177. this.areaInfo = e
  178. this.areaIdArr = [ e.provinceCode, e.cityCode, e.areaCode ]
  179. },
  180. openAddress(){
  181. // 省市区回显参数为省市区id数组
  182. this.$refs.applyAddress.open(this.areaIdArr)
  183. },
  184. // 去抽奖
  185. toLuckDraw() {
  186. uni.navigateBack()
  187. },
  188. // 查看详情
  189. viewsDetail(item){
  190. this.curRevice = item
  191. if(item.prizeType == 'GOODS'){
  192. this.showViews = true
  193. }else{
  194. this.showLjLd = true
  195. }
  196. },
  197. // 领奖
  198. lingjiang(item){
  199. this.curRevice = item
  200. if(item.prizeType == 'GOODS'){
  201. this.showAddr = true
  202. this.getAddress()
  203. }else{
  204. this.saveReceive()
  205. }
  206. },
  207. // 复制单号
  208. copyWlCode(){
  209. uni.setClipboardData({
  210. data: this.curRevice.expressNum,
  211. success: function () {
  212. console.log('success');
  213. }
  214. });
  215. },
  216. // 保存物流信息
  217. wlSubmit(){
  218. this.$refs.uForm.validate(valid => {
  219. if (valid) {
  220. console.log('验证通过');
  221. if (this.form.receiverName ==='') {
  222. uni.showToast({
  223. title: '请输入收货人姓名',
  224. icon: 'none'
  225. })
  226. return false
  227. }
  228. if (this.form.receiverPhone ==='') {
  229. uni.showToast({
  230. title: '请输入收货电话',
  231. icon: 'none'
  232. })
  233. return false
  234. }
  235. // 省市区
  236. if(this.areaIdArr.length == 0){
  237. uni.showToast({icon: 'none',title: '请选择省市区'})
  238. return
  239. }
  240. if (this.form.receiveAddress ==='') {
  241. uni.showToast({
  242. title: '请输入详细地址',
  243. icon: 'none'
  244. })
  245. return false
  246. }
  247. let params = {
  248. receiverName: this.form.receiverName,
  249. receiverPhone: this.form.receiverPhone,
  250. receiveAreasName: this.areaInfo.label.replace(/\-/g,','), // 地址名称
  251. receiveAreas: this.areaIdArr.join(','),
  252. receiveAddress: this.form.receiveAddress // 详细地址
  253. }
  254. if(this.form.id) {
  255. params.id = this.form.id
  256. }
  257. // 保存我的收货地址
  258. saveAddress(params).then(res=>{
  259. if(res.status == 200) {
  260. // 保存领奖收货信息
  261. this.saveReceive(params)
  262. }
  263. })
  264. }
  265. });
  266. },
  267. // 领奖
  268. saveReceive(params){
  269. let item = this.curRevice
  270. let isGoods = item.prizeType == 'GOODS'
  271. let data = {
  272. "luckyDrawWinNo": this.curRevice.luckyDrawWinNo
  273. }
  274. // 实物,发货地址
  275. if(isGoods){
  276. data.receiverName = params.receiverName
  277. data.receiverPhone = params.receiverPhone
  278. data.receiveAddress = params.receiveAreasName +' '+ params.receiveAddress
  279. }
  280. receive(data).then(res => {
  281. if(res.status == 200){
  282. uni.showToast({
  283. title: res.message,
  284. icon: 'none'
  285. })
  286. if(isGoods){
  287. this.showAddr = false
  288. }else{
  289. this.showLjLd = true
  290. }
  291. this.list = []
  292. this.getfindWinPrize()
  293. }
  294. })
  295. }
  296. }
  297. }
  298. </script>
  299. <style lang="less">
  300. .page-cont{
  301. width: 100%;
  302. padding: 20rpx;
  303. .list{
  304. display: flex;
  305. align-items: center;
  306. > view{
  307. padding: 15rpx;
  308. color: #FFFFFF;
  309. background-color: #01c9b2;
  310. border-right: 1px solid #FFFFFF;
  311. border-bottom: 1px solid #FFFFFF;
  312. text-align: center;
  313. }
  314. .no{
  315. width: 150rpx;
  316. }
  317. .names{
  318. width: 50%;
  319. flex-grow: 1;
  320. }
  321. .lingjiang{
  322. background-color: #ffaa00;
  323. color: #FFFFFF;
  324. width: 25%;
  325. }
  326. .viewsDetail{
  327. background-color: #008273;
  328. color: #FFFFFF;
  329. width: 25%;
  330. }
  331. }
  332. .tell{
  333. color: #0A98D5;
  334. }
  335. .lottery-content{
  336. height: 100%;
  337. position: relative;
  338. background: url(../../static/lottery_winbg1.png) no-repeat center top;
  339. background-size: 100% auto;
  340. .lottery-confrim-btn{
  341. width: 100%;
  342. display: flex;
  343. justify-content: center;
  344. font-size: 32rpx;
  345. border-top: 1px solid #eee;
  346. padding: 30rpx 0;
  347. color: #21d5c0;
  348. }
  349. .lottery-title{
  350. padding: 20rpx 30rpx;
  351. text-align: center;
  352. color: #FFFFFF;
  353. font-size: 36rpx;
  354. font-weight: bold;
  355. }
  356. .lottery-form{
  357. padding: 80rpx 30rpx 20rpx;
  358. > view{
  359. display: flex;
  360. padding: 10rpx;
  361. .labes{
  362. width: 150rpx;
  363. }
  364. >view{
  365. &:last-child{
  366. flex-grow: 1;
  367. width: 80%;
  368. color: #666;
  369. display: flex;
  370. align-items: center;
  371. text{
  372. word-break: break-all;
  373. }
  374. }
  375. }
  376. }
  377. }
  378. .lottery-msg{
  379. padding: 70rpx 60rpx;
  380. text-align: center;
  381. line-height: 42rpx;
  382. }
  383. .lottery-u-form{
  384. padding: 50rpx;
  385. .receiveAddress{
  386. width: 100%;
  387. line-height: 1.5em;
  388. box-sizing: border-box;
  389. font-style: normal;
  390. }
  391. }
  392. }
  393. }
  394. </style>