sureBuy.vue 11 KB

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