myJp.vue 10 KB

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