sureBuy.vue 12 KB

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