sureBuy.vue 12 KB

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