sureBuy.vue 11 KB

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