myJp.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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.prizeType == 'GOODS'?item.prizeDesc:(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. uni.showShareMenu({
  126. withShareTicket: true,
  127. menus: ['shareAppMessage', 'shareTimeline']
  128. })
  129. },
  130. onUnload() {
  131. this.form = {
  132. receiverName: '',
  133. receiverPhone: '',
  134. receiveAddress: '' // 详细地址
  135. }
  136. },
  137. methods: {
  138. goBack(){
  139. if(this.fromPage == 'usercenter'){
  140. uni.redirectTo({
  141. url: '/pagesA/luckDraw/luckDraw'
  142. })
  143. }else{
  144. uni.navigateBack()
  145. }
  146. },
  147. // 电话客服
  148. callPhone () {
  149. uni.makePhoneCall({
  150. phoneNumber: this.kfPhone
  151. })
  152. },
  153. getfindWinPrize(){
  154. uni.showLoading({
  155. mask: true,
  156. title: '正在加载...'
  157. })
  158. findWinPrize().then(res => {
  159. if(res.status == 200){
  160. this.list = res.data
  161. }
  162. uni.hideLoading()
  163. })
  164. },
  165. // 获取用户收货地址
  166. getAddress() {
  167. findAddressBycustomerNo({}).then(res => {
  168. console.log(res)
  169. if (res.status == 200&&res.data.length) {
  170. this.form = res.data[0]
  171. if (this.form.receiveAreasName) {
  172. this.areaIdArr = this.form.receiveAreas.split(',')
  173. this.areaInfo.label = this.form.receiveAreasName.replace(/\,/g,'-')
  174. }
  175. this.$u.vuex("vuex_OrderAddress",this.form)
  176. }
  177. })
  178. },
  179. // 选择省区市
  180. areaConfirm(e) {
  181. console.log('已选择的省市区', e)
  182. this.areaInfo = e
  183. this.areaIdArr = [ e.provinceCode, e.cityCode, e.areaCode ]
  184. },
  185. openAddress(){
  186. // 省市区回显参数为省市区id数组
  187. this.$refs.applyAddress.open(this.areaIdArr)
  188. },
  189. // 去抽奖
  190. toLuckDraw() {
  191. uni.navigateBack()
  192. },
  193. // 查看详情
  194. viewsDetail(item){
  195. this.curRevice = item
  196. if(item.prizeType == 'GOODS'){
  197. this.showViews = true
  198. }else{
  199. this.showLjLd = true
  200. }
  201. },
  202. // 领奖
  203. lingjiang(item){
  204. this.curRevice = item
  205. if(item.prizeType == 'GOODS'){
  206. this.showAddr = true
  207. this.getAddress()
  208. }else{
  209. this.saveReceive()
  210. }
  211. },
  212. // 复制单号
  213. copyWlCode(){
  214. uni.setClipboardData({
  215. data: this.curRevice.expressNum,
  216. success: function () {
  217. console.log('success');
  218. }
  219. });
  220. },
  221. // 保存物流信息
  222. wlSubmit(){
  223. this.$refs.uForm.validate(valid => {
  224. if (valid) {
  225. console.log('验证通过');
  226. if (this.form.receiverName ==='') {
  227. uni.showToast({
  228. title: '请输入收货人姓名',
  229. icon: 'none'
  230. })
  231. return false
  232. }
  233. if (this.form.receiverPhone ==='') {
  234. uni.showToast({
  235. title: '请输入收货电话',
  236. icon: 'none'
  237. })
  238. return false
  239. }
  240. // 省市区
  241. if(this.areaIdArr.length == 0){
  242. uni.showToast({icon: 'none',title: '请选择省市区'})
  243. return
  244. }
  245. if (this.form.receiveAddress ==='') {
  246. uni.showToast({
  247. title: '请输入详细地址',
  248. icon: 'none'
  249. })
  250. return false
  251. }
  252. let params = {
  253. receiverName: this.form.receiverName,
  254. receiverPhone: this.form.receiverPhone,
  255. receiveAreasName: this.areaInfo.label.replace(/\-/g,','), // 地址名称
  256. receiveAreas: this.areaIdArr.join(','),
  257. receiveAddress: this.form.receiveAddress // 详细地址
  258. }
  259. if(this.form.id) {
  260. params.id = this.form.id
  261. }
  262. // 保存我的收货地址
  263. saveAddress(params).then(res=>{
  264. if(res.status == 200) {
  265. // 保存领奖收货信息
  266. this.saveReceive(params)
  267. }
  268. })
  269. }
  270. });
  271. },
  272. // 领奖
  273. saveReceive(params){
  274. let item = this.curRevice
  275. let isGoods = item.prizeType == 'GOODS'
  276. let data = {
  277. "luckyDrawWinNo": this.curRevice.luckyDrawWinNo
  278. }
  279. // 实物,发货地址
  280. if(isGoods){
  281. data.receiverName = params.receiverName
  282. data.receiverPhone = params.receiverPhone
  283. data.receiveAddress = params.receiveAreasName +' '+ params.receiveAddress
  284. }
  285. receive(data).then(res => {
  286. if(res.status == 200){
  287. uni.showToast({
  288. title: res.message,
  289. icon: 'none'
  290. })
  291. if(isGoods){
  292. this.showAddr = false
  293. }else{
  294. this.showLjLd = true
  295. }
  296. this.list = []
  297. this.getfindWinPrize()
  298. }
  299. })
  300. }
  301. }
  302. }
  303. </script>
  304. <style lang="less">
  305. .page-cont{
  306. width: 100%;
  307. padding: 20rpx;
  308. .list{
  309. display: flex;
  310. align-items: center;
  311. > view{
  312. padding: 15rpx;
  313. color: #FFFFFF;
  314. background-color: #01c9b2;
  315. border-right: 1px solid #FFFFFF;
  316. border-bottom: 1px solid #FFFFFF;
  317. text-align: center;
  318. }
  319. .no{
  320. width: 150rpx;
  321. }
  322. .names{
  323. width: 50%;
  324. flex-grow: 1;
  325. }
  326. .lingjiang{
  327. background-color: #ffaa00;
  328. color: #FFFFFF;
  329. width: 25%;
  330. }
  331. .viewsDetail{
  332. background-color: #008273;
  333. color: #FFFFFF;
  334. width: 25%;
  335. }
  336. }
  337. .tell{
  338. color: #0A98D5;
  339. }
  340. .lottery-content{
  341. height: 100%;
  342. position: relative;
  343. background: url(../../static/lottery_winbg1.png) no-repeat center top;
  344. background-size: 100% auto;
  345. .lottery-confrim-btn{
  346. width: 100%;
  347. display: flex;
  348. justify-content: center;
  349. font-size: 32rpx;
  350. border-top: 1px solid #eee;
  351. padding: 30rpx 0;
  352. color: #21d5c0;
  353. }
  354. .lottery-title{
  355. padding: 20rpx 30rpx;
  356. text-align: center;
  357. color: #FFFFFF;
  358. font-size: 36rpx;
  359. font-weight: bold;
  360. }
  361. .lottery-form{
  362. padding: 80rpx 30rpx 20rpx;
  363. > view{
  364. display: flex;
  365. padding: 10rpx;
  366. .labes{
  367. width: 150rpx;
  368. }
  369. >view{
  370. &:last-child{
  371. flex-grow: 1;
  372. width: 80%;
  373. color: #666;
  374. display: flex;
  375. align-items: center;
  376. text{
  377. word-break: break-all;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. .lottery-msg{
  384. padding: 70rpx 60rpx;
  385. text-align: center;
  386. line-height: 42rpx;
  387. }
  388. .lottery-u-form{
  389. padding: 50rpx;
  390. .receiveAddress{
  391. width: 100%;
  392. line-height: 1.5em;
  393. box-sizing: border-box;
  394. font-style: normal;
  395. }
  396. }
  397. }
  398. }
  399. </style>