sureBuy.vue 11 KB

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