integralOrder.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. <template>
  2. <view class="exchangePrize">
  3. <!-- 表单 -->
  4. <view class="form">
  5. <view class="">
  6. <uni-forms :modelValue="formData">
  7. <uni-forms-item name="type" v-if="is_virtual == 0 ">
  8. <view class="selectType" @click="openSelect">
  9. <view class="uni-input">
  10. <text v-if="formData.type==''||formData.type==null"
  11. style="color: #999999 ;font-size: 30rpx;">请选择配送方式</text>
  12. <text v-if="formData.type!=''" style="font-size: 30rpx;">{{formData.type}}</text>
  13. </view>
  14. <image src="/static/icon/right.png"
  15. style="width: 14rpx;height: 24rpx;position: absolute;top:31rpx;right: 30rpx;">
  16. </image>
  17. </view>
  18. </uni-forms-item>
  19. <uni-forms-item name="name" v-if="formData.type!=''||isVerification==true">
  20. <uni-easyinput type="text" v-model="Data.receiver" placeholder="填写联系人" />
  21. </uni-forms-item>
  22. <uni-forms-item name="phone" v-if="formData.type!=''||isVerification==true">
  23. <uni-easyinput type="number" v-model="Data.phone" placeholder="填写联系电话" maxlength=11 />
  24. </uni-forms-item>
  25. <uni-forms-item name="region" v-if="formData.type=='快递配送'">
  26. <pickerAddress @change="change">
  27. <!-- <uni-easyinput type="text" v-model="formData.region" placeholder="所在地区" /> -->
  28. <view class="selectType">
  29. <view class="uni-input">
  30. <text v-if="formData.region==''||formData.region==null"
  31. style="color: #999999 ; font-size: 30rpx; ">所在地区</text>
  32. <text style="font-size: 30rpx;"
  33. v-if="formData.region!=''">{{formData.region}}</text>
  34. </view>
  35. <image src="/static/icon/right.png"
  36. style="width: 14rpx;height: 24rpx;position: absolute;top:31rpx;right: 30rpx;">
  37. </image>
  38. </view>
  39. </pickerAddress>
  40. </uni-forms-item>
  41. <uni-forms-item name="region" v-if="formData.type=='快递配送'">
  42. <textarea placeholder-style="#999" class="text-area" type="text" placeholder="详细地址"
  43. v-model="Data.address" />
  44. </uni-forms-item>
  45. <uni-forms-item name="region" v-if="formData.type=='到店自提'||isVerification==true">
  46. <view class="selectType" @click="openShop">
  47. <view class="uni-input">
  48. <text v-if="formData.shop==''||formData.shop==null"
  49. style="color: #999999 ; font-size: 30rpx; ">请选择门店</text>
  50. <text style="font-size: 30rpx;" v-if="formData.shop!=''">{{formData.shop}}</text>
  51. <text class="distance" v-if="formData.shop!=''">{{formData.distanceToMe}}km</text>
  52. </view>
  53. <image src="/static/icon/right.png"
  54. style="width: 14rpx;height: 24rpx;position: absolute;top:31rpx;right: 30rpx;">
  55. </image>
  56. </view>
  57. </uni-forms-item>
  58. </uni-forms>
  59. </view>
  60. </view>
  61. <!-- 产品信息 -->
  62. <view class="msg">
  63. <view class="title">
  64. <text>产品信息</text>
  65. </view>
  66. <view class="shopCard">
  67. <image :src="productDetail.cover_img?productDetail.cover_img:'http://t9.9026.com/imgs/Kudosbg.png'">
  68. </image>
  69. <view style="margin-left: 24rpx;">
  70. <text class="name">{{productDetail.name}}</text>
  71. <text class="tag">礼盒装 </text>
  72. </view>
  73. </view>
  74. <view class="shopNumber">
  75. <text>件数</text>
  76. <text>1件</text>
  77. </view>
  78. <view class="shopNumber">
  79. <text>积分</text>
  80. <text>{{productDetail.integral}}积分</text>
  81. </view>
  82. <view style="width: 694rpx;height: 4rpx;border: 2rpx solid #F2F2F2;margin-top: 38rpx;"></view>
  83. <view class="shopNumber">
  84. <text>合计</text>
  85. <text>{{productDetail.integral}}积分</text>
  86. </view>
  87. </view>
  88. <!-- 兑换按钮 -->
  89. <view class="bottombtn" @click="goExchange">
  90. <view class="btnitem">
  91. <text>确认兑换</text>
  92. </view>
  93. </view>
  94. <!-- 配送方式-->
  95. <uni-popup ref="Recipient" type="bottom" mask-background-color=" rgba(0,0,0,0.7);">
  96. <view class="pop">
  97. <view class="popuptitle">
  98. <view @click="cancelBtn" style="width: 68rpx;color: #999;font-size: 32rpx;">
  99. <text>取消</text>
  100. </view>
  101. <view>
  102. <text style="font-weight: bold; font-size: 32rpx; color: #080F18; ">配送方式</text>
  103. </view>
  104. <view @click="sureBtn" style="width: 68rpx;"><text
  105. style="font-size: 32rpx; color: #FF6200;line-height: 34rpx">确定</text></view>
  106. </view>
  107. <view class="chooselag">
  108. <view @click="companyed(item.name,index)" class="language"
  109. v-for="(item,index) in typeSelect " :key="index"
  110. :class="[activeIndex === index?'sgActive': ''] ">
  111. <text>{{item.name}}</text>
  112. </view>
  113. </view>
  114. </view>
  115. </uni-popup>
  116. <!-- 门店选择-->
  117. <uni-popup ref="shopSelected" type="bottom" mask-background-color=" rgba(0,0,0,0.7);">
  118. <view class="pop">
  119. <view class="popuptitle">
  120. <view @click="cancelShopBtn" style="width: 68rpx;color: #999;font-size: 32rpx;">
  121. <text>取消</text>
  122. </view>
  123. <view>
  124. <text style="font-weight: bold; font-size: 32rpx; color: #080F18; ">配送方式</text>
  125. </view>
  126. <view @click="sureShopBtn" style="width: 68rpx;"><text
  127. style="font-size: 32rpx; color: #FF6200;line-height: 34rpx">确定</text></view>
  128. </view>
  129. <view class="chooselag">
  130. <view@click="companyedShop(item.name,item.id,item.distanceToMe,index)"
  131. class="language" v-for="(item,index) in hotelList" :key="index"
  132. :class="[activeIndex2 === index?'sgActive': ''] ">
  133. <text>{{item.name}}</text>
  134. </view>
  135. </view>
  136. </view>
  137. </uni-popup>
  138. </view>
  139. </template>
  140. <script>
  141. import pickerAddress from '@/uni_modules/hu-pickerAddress/hu-pickerAddress.vue'
  142. export default {
  143. components: {
  144. pickerAddress
  145. },
  146. data() {
  147. return {
  148. //选中激活样式
  149. activeIndex: '',
  150. activeIndex2: '',
  151. //经纬度
  152. latitude: '',
  153. longitude: '',
  154. //实物奖品0,虚拟奖品1
  155. is_virtual: '',
  156. // activeIndex: null,
  157. // 是否核销
  158. isVerification: false,
  159. // 产品信息
  160. productDetail: '',
  161. // 表单数据
  162. formData: {
  163. // 表单数据
  164. type: '',
  165. region: '',
  166. shop: '',
  167. distanceToMe: ''
  168. },
  169. Data: {
  170. // 快递类型(1.快递发货 2.到店自提也是线下核销)
  171. express_type: '',
  172. // 收货人
  173. receiver: "",
  174. // 联系电话
  175. phone: '',
  176. // 地址ID,最小行政单位地区ID,express_type=1时必传
  177. area_id: '',
  178. // 详细地址,express_type=1时必传
  179. address: '',
  180. //门店ID,express_type=2时必传
  181. hotel_id: 0,
  182. // 产品ID
  183. product_id: '',
  184. // 产品规格ID
  185. attr:'',
  186. },
  187. // 配送方式
  188. typeSelect: [{
  189. name: '快递配送',
  190. }, {
  191. name: '到店自提',
  192. }],
  193. // 是否显示配送方式
  194. istype: true,
  195. // 选择门店
  196. hotelList: []
  197. }
  198. },
  199. onLoad(op) {
  200. console.log(op, "产品id")
  201. this.Data.product_id = op.product_id
  202. this.getProductDetail(op.product_id)
  203. },
  204. methods: {
  205. space(lat1, lng1, lat2, lng2) {
  206. var radLat1 = lat1 * Math.PI / 180.0;
  207. var radLat2 = lat2 * Math.PI / 180.0;
  208. var a = radLat1 - radLat2;
  209. var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  210. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  211. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  212. s = s * 6378.137;
  213. s = Math.round(s * 10000) / 10000;
  214. return s // 单位千米
  215. },
  216. //门店列表
  217. getHotel() {
  218. this.$api.hotel.getHotelList({
  219. page: 1,
  220. type: 2,
  221. latitude: this.latitude,
  222. longitude: this.longitude
  223. }).then(res => {
  224. this.hotelList = res.data.data
  225. this.hotelList.map(item => {
  226. item.distanceToMe = this.space(this.latitude, this.longitude, item.latitude, item
  227. .longitude).toFixed(1);
  228. return item;
  229. })
  230. console.log(this.hotelList, '-------->this.hotelList');
  231. })
  232. },
  233. //获取定位
  234. goLocation() {
  235. let _this = this
  236. uni.getLocation({
  237. type: "gcj02", //返回可以用于wx.openLocation的经纬度
  238. success: function(res) {
  239. _this.latitude = res.latitude
  240. _this.longitude = res.longitude
  241. },
  242. fail: function(res) {
  243. console.log(res)
  244. }
  245. })
  246. },
  247. // 获取产品信息
  248. getProductDetail(id) {
  249. this.$loading()
  250. this.$api.product.getProductDetail({
  251. product_id: id
  252. }).then(res => {
  253. console.log(res, "产品信息")
  254. this.$hideLoading()
  255. if (res.code == 0) {
  256. this.productDetail = res.data
  257. this.is_virtual = res.data.is_virtual
  258. if (this.is_virtual == 1) {
  259. this.isVerification = true
  260. this.Data.express_type = 2
  261. this.goLocation()
  262. setTimeout(() => {
  263. this.getHotel()
  264. }, 1000)
  265. }
  266. } else {
  267. uni.showToast({
  268. title: res.msg,
  269. icon: 'none'
  270. })
  271. }
  272. })
  273. },
  274. //订单兑换
  275. goExchange() {
  276. if (this.formData.type == '' && this.is_virtual == 0) {
  277. uni.showToast({
  278. icon: 'none',
  279. title: '请选择配送方式'
  280. })
  281. return
  282. }
  283. if (this.Data.receiver == '') {
  284. uni.showToast({
  285. icon: 'none',
  286. title: '请填写联系人'
  287. })
  288. return
  289. }
  290. if (this.Data.phone == '') {
  291. uni.showToast({
  292. icon: 'none',
  293. title: '请填写联系电话'
  294. })
  295. return
  296. }
  297. if (this.formData.region == '' && this.Data.express_type == 1) {
  298. uni.showToast({
  299. icon: 'none',
  300. title: '请填写所在地区'
  301. })
  302. return
  303. }
  304. if (this.Data.address == '' && this.Data.express_type == 1) {
  305. uni.showToast({
  306. icon: 'none',
  307. title: '请填写详细地址'
  308. })
  309. return
  310. }
  311. if (this.Data.hotel_id == '' && this.Data.express_type == 2) {
  312. uni.showToast({
  313. icon: 'none',
  314. title: '请选择门店'
  315. })
  316. return
  317. }
  318. if(this.is_virtual == 0){
  319. if(this.Data.express_type == 1){
  320. this.$api.product.integralExchange({
  321. ...this.Data
  322. }).then(res => {
  323. if (res.code == 0) {
  324. uni.navigateTo({
  325. url: '/pages/my/prize/exchangeDetail'
  326. })
  327. } else {
  328. uni.showToast({
  329. icon: 'none',
  330. title: res.msg
  331. })
  332. }
  333. })
  334. }else{
  335. let obj ={}
  336. obj.express_type = this.Data.express_type
  337. obj.product_id = this.Data.product_id
  338. obj.receiver = this.Data.receiver
  339. obj.phone = this.Data.phone
  340. obj.hotel_id = this.Data.hotel_id
  341. obj.attr = this.Data.attr
  342. this.$api.product.integralExchange({
  343. ...obj
  344. }).then(res => {
  345. if (res.code == 0) {
  346. uni.navigateTo({
  347. url: '/pages/my/prize/exchangeDetail'
  348. })
  349. } else {
  350. uni.showToast({
  351. icon: 'none',
  352. title: res.msg
  353. })
  354. }
  355. })
  356. }
  357. }else{
  358. let obj ={}
  359. obj.express_type = this.Data.express_type
  360. obj.product_id = this.Data.product_id
  361. obj.receiver = this.Data.receiver
  362. obj.phone = this.Data.phone
  363. obj.hotel_id = this.Data.hotel_id
  364. obj.attr = this.Data.attr
  365. this.$api.product.integralExchange({
  366. ...obj
  367. }).then(res => {
  368. if (res.code == 0) {
  369. uni.navigateTo({
  370. url: '/pages/my/prize/exchangeDetail'
  371. })
  372. } else {
  373. uni.showToast({
  374. icon: 'none',
  375. title: res.msg
  376. })
  377. }
  378. })
  379. }
  380. },
  381. change(ret) {
  382. this.formData.region = ret.data.join('-')
  383. this.Data.area_id = ret.code[2]
  384. },
  385. //打开门店弹框
  386. openShop() {
  387. this.$refs.shopSelected.open('bottom')
  388. },
  389. companyedShop(i, id, distance,index) {
  390. this.typestatus2 = i
  391. this.distanceToMe1 = distance
  392. this.activeIndex2= index
  393. this.Data.hotel_id = id
  394. },
  395. //确定按钮
  396. sureShopBtn() {
  397. if (this.typestatus2 == undefined) {
  398. uni.showToast({
  399. icon: "none",
  400. title: '请选择门店'
  401. })
  402. } else {
  403. this.formData.shop = this.typestatus2
  404. this.formData.distanceToMe = this.distanceToMe1
  405. this.$refs.shopSelected.close()
  406. }
  407. },
  408. //取消按钮
  409. cancelShopBtn() {
  410. this.$refs.shopSelected.close()
  411. },
  412. // 打开配送弹框
  413. openSelect() {
  414. this.$refs.Recipient.open('bottom')
  415. },
  416. //选择配送方式
  417. companyed(i, index) {
  418. this.typestatus1 = i
  419. this.activeIndex = index
  420. if (index == 0) {
  421. this.Data.express_type = 1
  422. } else if (index == 1) {
  423. this.Data.express_type = 2
  424. this.goLocation()
  425. setTimeout(() => {
  426. this.getHotel()
  427. }, 1000)
  428. }
  429. },
  430. //确定按钮
  431. sureBtn() {
  432. if (this.typestatus1 == undefined) {
  433. uni.showToast({
  434. icon: "none",
  435. title: '请选择配送方式'
  436. })
  437. } else {
  438. this.formData.type = this.typestatus1
  439. this.$refs.Recipient.close()
  440. }
  441. },
  442. //取消按钮
  443. cancelBtn() {
  444. this.$refs.Recipient.close()
  445. },
  446. }
  447. }
  448. </script>
  449. <style lang="scss" scoped>
  450. $pageColor:#F9F9F9;
  451. $bgColor:#FFFFFF;
  452. @mixin flexlayout {
  453. display: flex;
  454. align-items: center;
  455. justify-content: center;
  456. }
  457. .exchangePrize {
  458. height: 100%;
  459. // background: #f9f9f9;
  460. }
  461. .distance {
  462. position: absolute;
  463. right: 60rpx;
  464. top: 23rpx;
  465. }
  466. .uni-input-area {
  467. width: 100%;
  468. height: 98rpx;
  469. padding: 34rpx 20rpx;
  470. background: #FFFFFF;
  471. border-radius: 8rpx;
  472. border: 2rpx solid #EAEAEA;
  473. font-size: 30rpx;
  474. color: #000;
  475. line-height: 30rpx;
  476. }
  477. //底部弹框样式
  478. .pop {
  479. width: 100%;
  480. height: 616rpx;
  481. background: #FFFFFF;
  482. border-radius: 16rpx 16rpx 0 0;
  483. overflow: scroll;
  484. .popuptitle {
  485. position: fixed;
  486. top: 0;
  487. display: flex;
  488. width: 100%;
  489. padding: 0 30rpx;
  490. height: 122rpx;
  491. background: #fff;
  492. display: flex;
  493. align-items: center;
  494. justify-content: space-between;
  495. image {
  496. display: inline-block;
  497. width: 33rpx;
  498. height: 33rpx;
  499. border-radius: 1rpx;
  500. }
  501. }
  502. .chooselag {
  503. flex-direction: column;
  504. justify-content: center;
  505. align-items: center;
  506. background: #FFFFFF;
  507. padding: 0 30rpx;
  508. overflow-y: scroll;
  509. margin-top: 122rpx;
  510. .language {
  511. width: 100%;
  512. font-size: 32rpx;
  513. font-weight: 400;
  514. color: #777777;
  515. border-bottom: 1rpx #E2E4EA solid;
  516. display: flex;
  517. align-items: center;
  518. justify-content: center;
  519. padding-top: 40rpx;
  520. padding-bottom: 40rpx;
  521. }
  522. .sgActive{
  523. color: #FF6200 !important;
  524. font-weight: bold !important;
  525. }
  526. }
  527. }
  528. .text-area {
  529. width: 100%;
  530. height: 130rpx;
  531. padding: 34rpx 20rpx;
  532. background: #FFFFFF;
  533. border-radius: 8rpx;
  534. border: 2rpx solid #EAEAEA;
  535. font-size: 30rpx;
  536. color: #000;
  537. line-height: 30rpx;
  538. }
  539. ::v-deep .uni-forms-item {
  540. // height: 98rpx;
  541. margin-bottom: 0;
  542. margin-top: 24rpx;
  543. font-size: 30rpx !important;
  544. &:first-child {
  545. margin-top: 0;
  546. }
  547. }
  548. ::v-deep .is-input-border {
  549. background-color: #ffffff !important;
  550. border: 2rpx solid #EAEAEA !important;
  551. height: 98rpx;
  552. }
  553. ::v-deep .uni-icons {
  554. color: #c0c4cc !important;
  555. }
  556. ::v-deep .uni-easyinput__placeholder-class {
  557. font-size: 30rpx !important;
  558. color: #999 !important;
  559. }
  560. ::v-deep .uni-easyinput__content-input {
  561. font-size: 30rpx !important;
  562. color: #000 !important;
  563. }
  564. .form {
  565. background: $pageColor;
  566. width: 750rpx;
  567. padding: 24rpx 30rpx;
  568. box-sizing: border-box;
  569. .selectType {
  570. width: 690rpx;
  571. height: 98rpx;
  572. background: #FFFFFF;
  573. border-radius: 8rpx;
  574. border: 2rpx solid #EAEAEA;
  575. display: flex;
  576. align-items: center;
  577. padding-left: 20rpx;
  578. box-sizing: border-box;
  579. position: relative;
  580. }
  581. }
  582. .msg {
  583. width: 750rpx;
  584. height: 700rpx;
  585. background: $bgColor;
  586. border-radius: 12rpx 12rpx 0px 0px;
  587. padding: 32rpx 30rpx;
  588. .title {
  589. margin-bottom: 24rpx;
  590. text {
  591. font-size: 32rpx;
  592. font-family: PingFang-SC-Bold, PingFang-SC;
  593. font-weight: bold;
  594. color: #080F18;
  595. }
  596. }
  597. .shopCard {
  598. margin-top: 28rpx;
  599. width: 694rpx;
  600. height: 164rpx;
  601. background: #F4F5F6;
  602. border-radius: 10rpx;
  603. display: flex;
  604. align-items: center;
  605. image {
  606. width: 132rpx;
  607. height: 132rpx;
  608. margin-left: 16rpx;
  609. display: inline-block;
  610. border-radius: 10rpx;
  611. }
  612. .name {
  613. font-size: 28rpx;
  614. font-family: PingFangSC-Medium, PingFang SC;
  615. font-weight: 500;
  616. color: #080F18;
  617. display: block;
  618. }
  619. .tag {
  620. font-size: 24rpx;
  621. font-family: PingFang-SC-Medium, PingFang-SC;
  622. font-weight: 500;
  623. color: #666666;
  624. }
  625. }
  626. .shopNumber {
  627. display: flex;
  628. justify-content: space-between;
  629. align-items: center;
  630. margin-top: 25rpx;
  631. text {
  632. font-size: 26rpx;
  633. font-family: PingFang-SC-Medium, PingFang-SC;
  634. font-weight: 500;
  635. color: #000000;
  636. }
  637. }
  638. }
  639. .bottombtn {
  640. width: 690rpx;
  641. height: 92rpx;
  642. background: linear-gradient(270deg, #FF6200 0%, #FF9342 100%);
  643. border-radius: 12rpx;
  644. margin-left: 30rpx;
  645. position: fixed;
  646. bottom: 72rpx;
  647. @include flexlayout() .btnitem {
  648. @include flexlayout() text {
  649. font-size: 30rpx;
  650. font-family: PingFang-SC-Bold, PingFang-SC;
  651. font-weight: bold;
  652. color: $bgColor;
  653. }
  654. }
  655. }
  656. </style>