sureBuy.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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. address_id:'',
  195. }
  196. },
  197. onLoad(options) {
  198. this.order_id = options.order_id;
  199. this.store_id = options.store;
  200. // let prices = Number((options.prices/100).toFixed(2));
  201. // this.prices = prices;
  202. this.getorder(); // 获取订单详情
  203. uni.$on("getadress",(adress)=>{
  204. console.log("klkkkk")
  205. this.choseadress = adress;
  206. this.address_id = this.choseadress.address_id;
  207. //this.getorder();
  208. this.getralodprice();
  209. })
  210. },
  211. onUnload() {
  212. uni.$off();
  213. },
  214. methods: {
  215. readshouknow() {
  216. this.ishow = true;
  217. },
  218. confirmOrder() {
  219. this.ishow = false;
  220. },
  221. getread() {
  222. this.read = 4;
  223. },
  224. gethonename(e) {
  225. this.honename = e.detail;
  226. },
  227. getphone(e) {
  228. this.phone = e.detail;
  229. },
  230. getusername(e) {
  231. this.username = e.detail;
  232. },
  233. getCheckedin(e) {
  234. this.Checkedin = e.detail;
  235. },
  236. getnumberphone(e) {
  237. this.numberphone = e.detail;
  238. },
  239. getremark(e) {
  240. this.remark = e.detail;
  241. },
  242. // 获取订单详情
  243. getorder() {
  244. this.request({
  245. url: '/v2/order/og',
  246. method: 'POST',
  247. data: {
  248. order_id: this.order_id,
  249. store_id: this.store_id
  250. },
  251. success: (res) => {
  252. let { data } = res.data;
  253. this.store = data.store;
  254. let totalprice = 0;
  255. data.og_list.forEach(item => {
  256. let arr = item.goods_name.split(' ');
  257. item.desarray = arr[0];
  258. item.descire = item.goods_name.replace(arr[0], '');
  259. totalprice+=Number(item.goods_pay_price*item.goods_num);
  260. })
  261. this.hotelname = this.store.store_name
  262. this.reserve = this.store.store_name
  263. this.pricelist = data.og_list;
  264. this.firstprice = totalprice;
  265. this.prices = totalprice.toFixed(2);
  266. }
  267. })
  268. },
  269. // 付款
  270. goPay() {
  271. let reg_phone = /^1[3456789]\d{9}$/;
  272. if(this.radio == 1) {
  273. if(this.address_id == '') {
  274. this.$msg("请选择地址")
  275. return;
  276. }
  277. this.gopaymoment();
  278. }else if(this.radio == 0){
  279. if(this.hotelname == '') {
  280. this.$msg("请输入酒店名")
  281. return;
  282. }else if(this.honename == '') {
  283. this.$msg("请输入房间号")
  284. return;
  285. }else if( !reg_phone.test(this.phone)) {
  286. this.$msg("请输入正确手机号")
  287. return;
  288. }else if(this.username == '') {
  289. this.$msg("请输入收货人")
  290. return;
  291. }
  292. this.request({
  293. url:'/v2/address/add',
  294. method:'post',
  295. data: {
  296. is_free: 1,
  297. area_info: this.store.area_info,
  298. address_detail:this.hotelname + this.honename,
  299. address_mob_phone: this.phone,
  300. address_realname: this.username,
  301. area_id: this.store.region_id
  302. },
  303. success: (res) => {
  304. this.address_id = res.data.data.address_id;
  305. this.shipping_type = 1;
  306. this.gopaymoment();
  307. }
  308. })
  309. }else if(this.radio == 2) {
  310. if(this.reserve == '') {
  311. this.$msg("请输入预定酒店")
  312. return;
  313. }else if(this.Checkedin == '') {
  314. this.$msg("请输入入住人")
  315. return;
  316. }else if( !reg_phone.test(this.numberphone)) {
  317. this.$msg("请输入正确手机号")
  318. return;
  319. }else if(this.read !=4) {
  320. this.$msg("请阅读预定须知");
  321. return;
  322. }
  323. this.request({
  324. url:'/v2/address/add',
  325. method:'post',
  326. data: {
  327. is_free: 1,
  328. area_info: this.store.area_info,
  329. address_detail:this.reserve,
  330. address_mob_phone: this.numberphone,
  331. address_realname: this.Checkedin,
  332. area_id: this.store.region_id
  333. },
  334. success: (res) => {
  335. this.address_id = res.data.data.address_id;
  336. this.shipping_type = 1;
  337. this.gopaymoment();
  338. }
  339. })
  340. }
  341. },
  342. // 下单
  343. gopaymoment(){
  344. this.request({
  345. url:'/v2/order/create',
  346. method: 'post',
  347. data: {
  348. gorderid: this.order_id,
  349. address_id: this.address_id,
  350. store_id: this.store.store_id,
  351. shipping_type: this.shipping_type,
  352. remark: this.remark
  353. },
  354. success: (res) => {
  355. if(res.data.code == 1000) {
  356. let order_id = res.data.data.order_id; // 订单id
  357. let store_id = this.store.store_id;
  358. let prices = this.prices;
  359. let isform = 2;
  360. uni.redirectTo({
  361. url:`/pages/myOrder/paymoment?order_id=${order_id}&prices=${prices}&isform=${isform}&store_id=${store_id}`
  362. })
  363. }
  364. }
  365. })
  366. },
  367. // 核算运费
  368. getralodprice() {
  369. this.request({
  370. url: '/v2/entry/orderFreight',
  371. method: 'POST',
  372. data: {
  373. order_id: this.order_id,
  374. address_id: this.address_id
  375. },
  376. success:(res) => {
  377. let price = this.firstprice;
  378. this.ralodprice = Number(res.data.data.shipping_fee);
  379. this.prices = Number(price + this.ralodprice).toFixed(2);;
  380. }
  381. })
  382. },
  383. onChange(index) {
  384. this.radio = index;
  385. if(index == 1) {
  386. this.shipping_type = 0; // 订单付款快递类型
  387. }else {
  388. this.shipping_type = 1;
  389. }
  390. },
  391. goAdress() {
  392. uni.navigateTo({
  393. url: '../myOrder/adress',
  394. });
  395. }
  396. }
  397. }
  398. </script>
  399. <style lang="scss">
  400. .LinkAdress /deep/ .van-cell {
  401. border-top: 15upx solid #F5F5F5;
  402. border-bottom: 15upx solid #F5F5F5;
  403. }
  404. .wrapper{
  405. border-top: 15rpx solid #F5F5F5;
  406. border-bottom: 15rpx solid #F5F5F5;
  407. padding: 0 32upx;
  408. background-color: #fff;
  409. }
  410. .u-box {
  411. padding: 15upx 0;
  412. }
  413. .topTip {
  414. display: flex;
  415. align-items: center;
  416. justify-content: space-between;
  417. padding: 20upx 36upx;
  418. border-bottom: 1px solid #F5F5F5;
  419. background-color: #fff;
  420. }
  421. .changewidth {
  422. color: #303133;
  423. font-size: 32upx;
  424. font-weight: 100!important;
  425. }
  426. .van-card {
  427. background-color: #fff!important;
  428. }
  429. .shoplist {
  430. display: flex;
  431. justify-content: space-between;
  432. align-items: center;
  433. }
  434. .adressbutton {
  435. position: fixed;
  436. bottom: 0;
  437. width: 100%;
  438. .buttonStatus {
  439. display: flex;
  440. text-align: left;
  441. height: 100upx;
  442. line-height: 100upx;
  443. .deleteOrder {
  444. flex: 6;
  445. color: #303133;
  446. font-size: 32upx;
  447. border-top: 1px solid #f5f5f5;
  448. background-color: #fff;
  449. padding: 0 0 0 32upx;
  450. }
  451. .payOrder {
  452. flex: 3;
  453. font-size: 32upx;
  454. color: #fff;
  455. background-color: #D9332E;
  456. text-align: center;
  457. }
  458. }
  459. }
  460. </style>