sureBuy.vue 11 KB

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