sureBuy.vue 11 KB

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