sureBuy.vue 11 KB

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