sureBuy.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <view style="width: 100%;height: 100vh;background-color: #F5F5F5;">
  3. <scroll-view class="floor-list"
  4. :scroll-top="scrollTop" scroll-y="true"
  5. :refresher-enabled="false">
  6. <van-radio-group >
  7. <van-cell-group v-for="(item, index) in list" :key="index" >
  8. <van-cell :border="false" :title="item.title" @click="onChange(index)" >
  9. <template slot="right-icon">
  10. <van-radio-group style="width: 20upx;" :value="radio" >
  11. <van-radio checked-color="#D9332E" :name="index" >
  12. </van-radio>
  13. </van-radio-group>
  14. </template>
  15. </van-cell>
  16. </van-cell-group>
  17. </van-radio-group>
  18. <view v-if="is_traffic == 0 && radio === 0" style="background-color: #D9332E;color: #fff;margin: 10upx 0; padding: 0 32upx;">
  19. 酒店现在是休息时间,可能无法及时为您配送
  20. </view>
  21. <view v-if="radio === 0" style="border-top: 15upx solid #F5F5F5; border-bottom: 15upx solid #F5F5F5;">
  22. <van-field
  23. @change="gethotelname"
  24. :value="hotelname"
  25. style="color: #323233;"
  26. label="酒店"
  27. readonly
  28. placeholder="请输入酒店" />
  29. <view @click="goshopvalue">
  30. <van-field
  31. :disabled="first==1&&!pleasesure"
  32. @change="getplaese"
  33. :value="honename"
  34. label="房间号"
  35. placeholder="请输入房间号" />
  36. </view>
  37. <van-field
  38. @change="getusername"
  39. :value="username"
  40. label="收货人"
  41. placeholder="请输入收货人"/>
  42. <van-field
  43. @change="getphone"
  44. :value="phone"
  45. label="手机号"
  46. placeholder="请输入手机号"
  47. />
  48. </view>
  49. <view v-if="radio === 2"
  50. style="border-top: 15upx solid #F5F5F5; border-bottom: 15upx solid #F5F5F5;">
  51. <van-field
  52. @change="getreserve"
  53. :value="reserve"
  54. readonly
  55. label="预订酒店"
  56. placeholder="请输入预订酒店"/>
  57. <van-field
  58. @change="getCheckedin"
  59. :value="Checkedin"
  60. label="入住人"
  61. placeholder="请输入入住人"/>
  62. <van-field
  63. @change="getnumberphone"
  64. :value="numberphone"
  65. label="手机号"
  66. placeholder="请输入手机号"/>
  67. <van-field @change="getremark" :value="remark" label="备注" placeholder="请输入备注" />
  68. </view>
  69. <view v-if="radio == 2">
  70. <van-radio-group >
  71. <van-cell-group >
  72. <van-cell :border="false">
  73. <template slot="title">
  74. 我已阅读并同意 <span @click="readshouknow" style="color: #007AFF">《预订须知》</span>
  75. </template>
  76. <template @click="getread" slot="right-icon">
  77. <van-radio-group style="width: 20upx;" :value="read" >
  78. <van-radio checked-color="#D9332E" :name="4" >
  79. </van-radio>
  80. </van-radio-group>
  81. </template>
  82. </van-cell>
  83. </van-cell-group>
  84. </van-radio-group>
  85. </view>
  86. <van-dialog
  87. use-slot
  88. :show="pleasesure"
  89. :showCancelButton='true'
  90. cancel-button-text="返回"
  91. @confirm="confirmstore"
  92. confirm-button-color="#D9332E"
  93. @cancel="cancelstore">
  94. <view style="padding: 50upx 32rpx;text-align: center;">
  95. <view style="padding: 15upx 0;">购物前请确认</view>
  96. <view style="padding: 15upx 0;font-size: 38rpx;color: #D9332E;font-weight: bold;">{{hotelname}}</view>
  97. <view style="padding: 15upx 0;">是否您入住的酒店</view>
  98. </view>
  99. </van-dialog>
  100. <van-dialog use-slot title="预订须知" :show="ishow" @confirm="confirmOrder" :show-cancel-button="false">
  101. <view style="padding: 0 32rpx;">
  102. <scroll-view style="height: 40vh;" :scroll-top="scrollTop" scroll-y="true" :refresher-enabled="false">
  103. <rich-text :nodes="store.buy_notice"></rich-text>
  104. </scroll-view>
  105. </view>
  106. </van-dialog>
  107. <van-cell v-if="radio === 1&&choseadress == '' " @click="goAdress" class="LinkAdress" title="选择地址" is-link/>
  108. <view v-if="radio === 1&&choseadress != ''" @click="goAdress" class="wrapper">
  109. <view class="u-box" >
  110. <text class="name" style="padding-right: 20upx;">{{choseadress.address_realname}}</text>
  111. <text class="mobile">{{choseadress.address_mob_phone}}</text>
  112. </view>
  113. <view class="u-box">
  114. <text class="address">{{choseadress.area_info}} {{choseadress.address_detail}}</text>
  115. </view>
  116. </view>
  117. <view @tap="goDetail()" class="cart-list">
  118. <view class="topTip">
  119. <view style="display: flex;align-items: center;">
  120. <image v-if="store.store_id&&store.store_banner" :src="pictureUrl+'/uploads/home/store/'+store.store_id+'/'+store.store_banner" style="border-radius: 50%;
  121. width: 50upx;height: 50upx;"></image>
  122. <span style="padding-left: 8upx;">{{store.store_name}}</span>
  123. </view>
  124. </view>
  125. <view v-for="(item,index) in pricelist" :key="index" class="shoplist" style="background-color: #fff;">
  126. <view>
  127. <van-card
  128. title-class="changewidth"
  129. price-class ="priceClass"
  130. :price="item.goods_price"
  131. :desc="item.descire+'X'+item.goods_num"
  132. :title="item.desarray"
  133. :thumb="pictureUrl + '/uploads/home/store/goods/' + item.goods_image.substr(0, item.goods_image.indexOf('\_')) + '/' + item.goods_image"
  134. >
  135. </van-card>
  136. </view>
  137. </view>
  138. <view class="topTip" style="border-top: 1px solid #eee;" v-if="radio === 1">
  139. <view style="font-size: 28upx;">运费:¥{{ralodprice}}</view>
  140. </view>
  141. </view>
  142. </scroll-view>
  143. <!-- 底部付款 -->
  144. <view class="adressbutton">
  145. <view class="buttonStatus">
  146. <view @click="estimate" v-if="radio == 1" class="deleteOrder">应付<span>¥{{prices2}}</span></view>
  147. <view @click="estimate" v-else class="deleteOrder">应付<span>¥{{prices}}</span></view>
  148. <view class="payOrder" @click="goPay">付款</view>
  149. </view>
  150. </view>
  151. </view>
  152. </template>
  153. <script>
  154. import {
  155. mapMutations,mapState
  156. } from 'vuex'
  157. export default {
  158. data() {
  159. return {
  160. is_traffic: 1,
  161. pleasesure: false,
  162. first: 1,
  163. scrollTop: 0,
  164. ishow: false,
  165. firstprice: 0,
  166. read: 0,
  167. hotelname:'', //
  168. honename:'',
  169. phone:'',
  170. username:'',
  171. reserve:'', // yudingjiudian
  172. Checkedin:'',
  173. numberphone:'',
  174. remark:'',
  175. ralodprice: 0,
  176. prices:'',//没快递的费用
  177. prices2:'',//带快递的费用
  178. pictureUrl: this.pictureUrl,
  179. list:[
  180. {title:'请送到我的房间'},
  181. {title:'快递到我的地址'},
  182. {title:'处理我的客房预订'}
  183. ],
  184. shipping_type: 0,
  185. radio: 0,
  186. store: {},
  187. store_id:'',
  188. pricelist: [],
  189. choseadress: '',
  190. order_id:'',
  191. address_id:'',
  192. }
  193. },
  194. onLoad(options) {
  195. this.order_id = options.order_id;
  196. this.store_id = options.store;
  197. this.getorder(); // 获取订单详情
  198. this.getuserinfo(); // 获取会员详情
  199. uni.$on("getadress",(adress)=>{
  200. this.choseadress = adress;
  201. this.address_id = this.choseadress.address_id;
  202. this.getralodprice();
  203. })
  204. },
  205. onUnload() {
  206. uni.$off();
  207. },
  208. methods: {
  209. // 确定入住酒店
  210. confirmstore() {
  211. this.pleasesure = false;
  212. },
  213. // 返回确认入住酒店
  214. cancelstore() {
  215. uni.navigateBack();
  216. },
  217. getuserinfo() {
  218. this.request({
  219. url:'/v2/member/info',
  220. method:'GET',
  221. success: (res)=>{
  222. let { data } = res.data;
  223. this.username = data.member_truename;
  224. this.phone = data.member_mobile;
  225. this.numberphone = data.member_mobile;
  226. this.Checkedin = data.member_truename;
  227. }
  228. })
  229. },
  230. readshouknow() {
  231. if(this.store.buy_notice!='') {
  232. this.ishow = true;
  233. }else {
  234. this.$msg("暂无预订须知哦")
  235. }
  236. },
  237. confirmOrder() {
  238. this.ishow = false;
  239. },
  240. getread() {
  241. this.read = 4;
  242. },
  243. getplaese(e) {
  244. this.honename = e.detail;
  245. },
  246. goshopvalue() {
  247. if(!this.pleasesure && this.first == 1) {
  248. this.pleasesure = true;
  249. this.first = 2;
  250. return;
  251. }
  252. },
  253. getphone(e) {
  254. this.phone = e.detail;
  255. },
  256. getusername(e) {
  257. this.username = e.detail;
  258. },
  259. getCheckedin(e) {
  260. this.Checkedin = e.detail;
  261. },
  262. getnumberphone(e) {
  263. this.numberphone = e.detail;
  264. },
  265. getremark(e) {
  266. this.remark = e.detail;
  267. },
  268. // 获取订单详情
  269. getorder() {
  270. this.request({
  271. url: '/v2/order/og',
  272. method: 'POST',
  273. data: {
  274. order_id: this.order_id,
  275. store_id: this.store_id
  276. },
  277. success: (res) => {
  278. let { data } = res.data;
  279. this.store = data.store;
  280. let totalprice = 0;
  281. data.og_list.forEach(item => {
  282. let arr = item.goods_name.split(' ');
  283. item.desarray = arr[0];
  284. item.descire = item.goods_name.replace(arr[0], '');
  285. totalprice+=Number(item.goods_pay_price*item.goods_num);
  286. })
  287. this.is_traffic = data.is_traffic;
  288. this.hotelname = this.store.store_name
  289. this.reserve = this.store.store_name
  290. this.pricelist = data.og_list;
  291. this.firstprice = totalprice;
  292. this.prices = totalprice.toFixed(2);
  293. }
  294. })
  295. },
  296. // 付款
  297. goPay() {
  298. let reg_phone = /^1[3456789]\d{9}$/;
  299. if(this.radio == 1) {
  300. if(this.address_id == '') {
  301. this.$msg("请选择地址")
  302. return;
  303. }
  304. this.gopaymoment();
  305. }else if(this.radio == 0){
  306. if(this.hotelname == '') {
  307. this.$msg("请输入酒店名")
  308. return;
  309. }else if(this.honename == '') {
  310. this.$msg("请输入房间号")
  311. return;
  312. }else if( !reg_phone.test(this.phone)) {
  313. this.$msg("请输入正确手机号")
  314. return;
  315. }else if(this.username == '') {
  316. this.$msg("请输入收货人")
  317. return;
  318. }
  319. this.request({
  320. url:'/v2/address/add',
  321. method:'post',
  322. data: {
  323. is_free: 1,
  324. area_info: this.store.area_info,
  325. address_detail:this.hotelname + this.honename,
  326. address_mob_phone: this.phone,
  327. address_realname: this.username,
  328. area_id: this.store.region_id
  329. },
  330. success: (res) => {
  331. this.address_id = res.data.data.address_id;
  332. this.shipping_type = 1;
  333. this.gopaymoment();
  334. }
  335. })
  336. }else if(this.radio == 2) {
  337. if(this.reserve == '') {
  338. this.$msg("请输入预订酒店")
  339. return;
  340. }else if(this.Checkedin == '') {
  341. this.$msg("请输入入住人")
  342. return;
  343. }else if( !reg_phone.test(this.numberphone)) {
  344. this.$msg("请输入正确手机号")
  345. return;
  346. }else if(this.read !=4) {
  347. this.$msg("请阅读预订须知");
  348. return;
  349. }
  350. this.request({
  351. url:'/v2/address/add',
  352. method:'post',
  353. data: {
  354. is_free: 1,
  355. area_info: this.store.area_info,
  356. address_detail:this.reserve,
  357. address_mob_phone: this.numberphone,
  358. address_realname: this.Checkedin,
  359. area_id: this.store.region_id
  360. },
  361. success: (res) => {
  362. this.address_id = res.data.data.address_id;
  363. this.shipping_type = 1;
  364. this.gopaymoment();
  365. }
  366. })
  367. }
  368. },
  369. // 下单
  370. gopaymoment(){
  371. this.request({
  372. url:'/v2/order/create',
  373. method: 'post',
  374. data: {
  375. gorderid: this.order_id,
  376. address_id: this.address_id,
  377. store_id: this.store.store_id,
  378. shipping_type: this.shipping_type,
  379. remark: this.remark
  380. },
  381. success: (res) => {
  382. if(res.data.code == 1000) {
  383. let order_id = res.data.data.order_id; // 订单id
  384. let store_id = this.store.store_id;
  385. var prices =this.radio == 1? this.prices2:this.prices;
  386. let isform = 2;
  387. uni.redirectTo({
  388. url:`/pages/myOrder/paymoment?order_id=${order_id}&prices=${prices}&isform=${isform}&store_id=${store_id}`
  389. })
  390. }
  391. }
  392. })
  393. },
  394. // 核算运费
  395. getralodprice() {
  396. this.request({
  397. url: '/v2/entry/orderFreight',
  398. method: 'POST',
  399. data: {
  400. order_id: this.order_id,
  401. address_id: this.address_id
  402. },
  403. success:(res) => {
  404. let price = this.firstprice;
  405. this.ralodprice = Number(res.data.data.shipping_fee);
  406. this.prices2 = Number(price + this.ralodprice).toFixed(2);;
  407. }
  408. })
  409. },
  410. onChange(index) {
  411. this.radio = index;
  412. if(index == 1) {
  413. this.shipping_type = 0; // 订单付款快递类型
  414. }else {
  415. this.shipping_type = 1;
  416. }
  417. },
  418. goAdress() {
  419. uni.navigateTo({
  420. url: '../myOrder/adress',
  421. });
  422. }
  423. }
  424. }
  425. </script>
  426. <style lang="scss">
  427. .LinkAdress /deep/ .van-cell {
  428. border-top: 15upx solid #F5F5F5;
  429. border-bottom: 15upx solid #F5F5F5;
  430. }
  431. .wrapper{
  432. border-top: 15rpx solid #F5F5F5;
  433. border-bottom: 15rpx solid #F5F5F5;
  434. padding: 0 32upx;
  435. background-color: #fff;
  436. }
  437. .u-box {
  438. padding: 15upx 0;
  439. }
  440. .topTip {
  441. display: flex;
  442. align-items: center;
  443. justify-content: space-between;
  444. padding: 20upx 36upx;
  445. border-bottom: 1px solid #F5F5F5;
  446. background-color: #fff;
  447. }
  448. .changewidth {
  449. color: #303133;
  450. font-size: 32upx;
  451. font-weight: 100!important;
  452. }
  453. .van-card {
  454. background-color: #fff!important;
  455. }
  456. .shoplist {
  457. display: flex;
  458. justify-content: space-between;
  459. align-items: center;
  460. }
  461. .adressbutton {
  462. position: fixed;
  463. bottom: 0;
  464. width: 100%;
  465. .buttonStatus {
  466. display: flex;
  467. text-align: left;
  468. height: 100upx;
  469. line-height: 100upx;
  470. .deleteOrder {
  471. flex: 6;
  472. color: #303133;
  473. font-size: 32upx;
  474. border-top: 1px solid #f5f5f5;
  475. background-color: #fff;
  476. padding: 0 0 0 32upx;
  477. }
  478. .payOrder {
  479. flex: 3;
  480. font-size: 32upx;
  481. color: #fff;
  482. background-color: #D9332E;
  483. text-align: center;
  484. }
  485. }
  486. }
  487. </style>