myJp.vue 10 KB

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