sureBuy.vue 11 KB

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