sureBuy.vue 13 KB

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