index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <view class="container" :style="{ height: winHeight+ 'px' }">
  3. <!-- 状态栏高度 -->
  4. <view :style="{ height: `${statusBarHeight+20}px` }"></view>
  5. <!-- 进行中/历史订单 -->
  6. <view class="status-bar">
  7. <view>
  8. <text :class="isShow? 'status-true': 'status-false'" @click="statusClick">外卖配送</text>
  9. <text :class="!isShow? 'status-true': 'status-false'" @click="statusClick">到店自取<text class="box-txt">(15分钟后取餐)</text></text>
  10. </view>
  11. </view>
  12. <view style="background-color: white;border-radius: 23rpx;margin-bottom: 10rpx;padding: 19rpx 38rpx 38rpx 38rpx">
  13. <view class='address' @tap='onAddress'>
  14. <view class='addressCon' v-if="addressInfo.realName">
  15. <view class='name acea-row boxnamae'>
  16. <view class="line1 select-name">{{addressInfo.realName}}</view>
  17. <view class='phone'>{{addressInfo.phone}}</view>
  18. </view>
  19. <view class="acea-row">
  20. <view ><text class='default font_color' v-if="addressInfo.isDefault">[默认]</text>{{addressInfo.province}}{{addressInfo.city}}{{addressInfo.district}}{{ addressInfo.street}}{{addressInfo.detail}}</view>
  21. </view>
  22. </view>
  23. <view class='addressCon' v-else>
  24. <view class='setaddress'>设置收货地址</view>
  25. </view>
  26. <view class='iconfont icon-jiantou ' style="font-size: 30rpx;"></view>
  27. </view>
  28. <view class="item-go" @tap="goIndex = true" :class="goIndex ? 'item-go-avt' : ''">
  29. <text style="font-weight: 600;font-size: 27rpx;">立即配送</text>
  30. <text style="font-weight: 500;font-size: 23rpx;margin-left: 76rpx">预计10:12送达</text>
  31. <image class="go-img"></image>
  32. </view>
  33. <view style="margin-top: 10rpx;" class="item-go" @tap="goIndex = false" :class="!goIndex ? 'item-go-avt' : ''">
  34. <text style="font-weight: 600;font-size: 27rpx;">预约配送</text>
  35. <text style="font-weight: 500;font-size: 23rpx;margin-left: 76rpx">选择时间 》</text>
  36. <image class="go-img"></image>
  37. </view>
  38. </view>
  39. <view class="item-goods">
  40. <text>{{detils.merchantInfoList[0].merName}}</text>
  41. <view class="good" v-for="(good, key) in goods_list" :key="key">
  42. <image :src="good.image" class="image"></image>
  43. <view class="right">
  44. <text class="name">{{ good.productName }}</text>
  45. <text class="tips">x {{ good.payNum }}</text>
  46. <view class="price_and_action">
  47. <text class="price">¥{{ good.price }}</text>
  48. <view class="btn-group">
  49. <view class="dot"></view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view style="width: 100%; height: 2rpx;border: 2rpx dashed #D6D7DC;position: relative;bottom: 20rpx;"></view>
  55. <view class='item-con'>
  56. <text>打包费</text>
  57. <text>¥2</text>
  58. </view>
  59. <view class='item-con' style="margin: 0;">
  60. <text>用户配送费</text>
  61. <text style="text-decoration: line-through;">¥2 <text>免费配送</text></text>
  62. </view>
  63. <view style="font-weight: 400;font-size: 21rpx;color: #999999;margin-bottom: 10rpx;">配送高峰期,可能配送费上调</view>
  64. <view class='item-con'>
  65. <text @tap="isZhuan = !isZhuan">已享优惠 <text :style="{ transform: isZhuan ? 'rotate(90deg)' : 'rotate(-90deg)'}"
  66. class='iconfont icon-jiantou xuanzhuan' style="font-size: 22rpx;display: inline-block;"></text></text>
  67. <text>- ¥2</text>
  68. </view>
  69. <view v-if="isZhuan" class='item-con' style="background: #F8F9FB;padding: 8rpx 19rpx;font-weight: 500;font-size: 21rpx;color: #FF6702;">
  70. <text>活动红包</text>
  71. <text>- ¥2</text>
  72. </view>
  73. <!-- 备注 -->
  74. <view>备注:</view>
  75. <textarea class="remark-txt" v-model="remark">
  76. </textarea>
  77. </view>
  78. <viwe style="height: 200rpx;"></viwe>
  79. <!-- 购物车栏 begin -->
  80. <view class="cart-box" :style="{top: (winHeight - 100) + 'px'}">
  81. <view style="margin-left: 39rpx;">
  82. <view style="font-weight: 600;font-size: 27rpx;color: #FFFFFF;" class="price">¥{{ total }}</view>
  83. <text style="font-weight: 400;font-size: 23rpx;color: #999999;">已优惠¥2</text>
  84. </view>
  85. <button type="primary" class="pay-btn bg-color" @tap="orderCreate">
  86. 去支付
  87. </button>
  88. </view>
  89. <!-- 购物车栏 end -->
  90. </view>
  91. </template>
  92. <script>
  93. import {
  94. getAddressDetail,
  95. getAddressDefault,
  96. getAddressList,
  97. } from '@/api/user.js';
  98. import {
  99. loadPreOrderApi,
  100. orderCreate
  101. } from '@/api/order.js';
  102. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  103. let app = getApp();
  104. export default {
  105. data() {
  106. return {
  107. total: 0,
  108. statusBarHeight: app.globalData.statusBarHeight,
  109. navigationBarHeight: 0,
  110. winHeight: 0,
  111. isZhuan: true,
  112. isShow: true,
  113. goIndex: true,
  114. orderNo: '', //预下单订单号
  115. addressInfo: {}, //地址信息
  116. addressId: 0, //地址id
  117. goods_list: [], //购物车数据
  118. cart: [],
  119. detils:'',//详情数据
  120. remark:'',//备注
  121. }
  122. },
  123. //下拉刷新
  124. onPullDownRefresh() {
  125. },
  126. onLoad(options) {
  127. let that = this;
  128. that.getAddressList()//获取地址
  129. that.orderNo=options.orderNo
  130. console.log('订单号',that.orderNo)
  131. that.loadPreOrderApi() //获取详情
  132. // 获取app德地址
  133. const app = getApp();
  134. let addressList=app.globalData.addressList
  135. uni.getSystemInfo({
  136. success: function(res) {
  137. that.winHeight = res.windowHeight
  138. },
  139. });
  140. //首页数据加载
  141. // this.getIndexConfig();
  142. // #ifdef MP-WEIXIN
  143. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  144. const custom = wx.getMenuButtonBoundingClientRect()
  145. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  146. this.navigationBarHeight = custom.height + (custom.top - this.statusBarHeight) * 2
  147. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  148. // #endif
  149. this.cart = uni.getStorageSync('cart')
  150. },
  151. onShow() {
  152. this.getAddressList()//获取地址
  153. },
  154. methods: {
  155. //订单创建
  156. orderCreate(){
  157. let orderMerchantRequestList = [] //数组
  158. let merId=this.detils.merchantInfoList[0].merId // 商户id
  159. orderMerchantRequestList.push({
  160. merId:merId, // 商户id
  161. remark:this.remark, // 备注
  162. shippingType: 1, // 快递类型: 1-快递配送,2-到店自提,3-虚拟发货
  163. userCouponId: 0, // 惠券编号(不选时为0)
  164. })
  165. orderCreate({
  166. isUseIntegral:false, // 是否使用积分
  167. addressId:this.addressInfo.id, //收货地址id
  168. orderExtend: JSON.stringify([{ key: 'value' }, { field: 'data' }]), //系统表单内容
  169. orderMerchantRequestList:orderMerchantRequestList, //订单商户对象
  170. platUserCouponId:0,//用户平台优惠券编号(不选时为0)
  171. preOrderNo:this.orderNo,//预下单订单号
  172. systemFormId: '',//系统表单ID
  173. traceId:"1 15N4MJksUcgG7onuaA9xuvoZwoLatM4mAE21CqXmMz6",
  174. }).then(res=>{
  175. console.log('创建',res)
  176. let data=res.data
  177. if(res.code){
  178. let url = `/pages/goods/order_payment/index?orderNo=${data.orderNo}&payPrice=${data.payPrice}`
  179. uni.redirectTo({
  180. url: url
  181. });
  182. }
  183. })
  184. },
  185. // 详情数据
  186. loadPreOrderApi(){
  187. loadPreOrderApi(this.orderNo).then(res=>{
  188. console.log('详情数据',res)
  189. if(res.code==200){
  190. let data=res.data
  191. this.detils=data
  192. this.goods_list=data.merchantInfoList[0].orderInfoList //购物车数据
  193. // 总价
  194. this.total = (this.goods_list.reduce((acc, cur) => acc + cur.payNum * cur.price, 0)).toFixed(2)
  195. }
  196. })
  197. },
  198. // 获取地址数据
  199. getAddressList(){
  200. getAddressList().then(res=>{
  201. console.log('地址',res)
  202. if(res.code=200){
  203. this.addressInfo=res.data.find(item => item.isDefault === true);
  204. console.log('默认地址',this.addressInfo)
  205. }
  206. })
  207. },
  208. statusClick() {
  209. this.isShow = !this.isShow;
  210. },
  211. onAddress: function() {
  212. uni.navigateTo({
  213. url: '/pages/address/user_address_list/index?orderNo=' + this.orderNo
  214. });
  215. },
  216. /*
  217. * 获取默认收货地址或者获取某条地址信息
  218. */
  219. getaddressInfo: function() {
  220. // if (this.addressId) {
  221. getAddressDetail(this.addressId).then(res => {
  222. console.log('地址信息',res)
  223. if (res.data) {
  224. res.data.isDefault = res.data.isDefault;
  225. this.addressInfo = res.data || {};
  226. }
  227. })
  228. // }
  229. },
  230. },
  231. mounted() {
  232. },
  233. }
  234. </script>
  235. <style lang="scss" scoped>
  236. .bg-color {
  237. background-color: $bg-color-primary;
  238. }
  239. .status-bar {
  240. display: flex;
  241. align-items: center;
  242. justify-content: center;
  243. height: 125rpx;
  244. background-color: #FF6702;
  245. text-align: center;
  246. padding: 20px 0 16rpx 0;
  247. }
  248. .status-bar view {
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. background: #EB5E00;
  253. border-radius: 37rpx;
  254. }
  255. .status-true {
  256. display: inline-block;
  257. width: 326rpx;
  258. padding: 10rpx 0;
  259. background-color: white;
  260. color: #FF6600;
  261. border-radius: 37rpx;
  262. }
  263. .status-false {
  264. display: inline-block;
  265. width: 326rpx;
  266. padding: 10rpx 0;
  267. color: #FFCBA9;
  268. border-radius: 37rpx;
  269. }
  270. .icon-jiantou {
  271. font-size: 26rpx;
  272. color: #515151;
  273. margin-left: 14rpx;
  274. }
  275. .address {
  276. margin-bottom: 40rpx;
  277. display: flex;
  278. align-items: center;
  279. justify-content: space-between;
  280. }
  281. .item-go {
  282. position: relative;
  283. width: 100%;
  284. padding: 20rpx 0;
  285. padding-left: 39rpx;
  286. background: #FFFFFF;
  287. border-radius: 15rpx;
  288. border: 2rpx solid #D6D7DC;
  289. }
  290. .item-go-avt {
  291. position: relative;
  292. color: #FF6702;
  293. background: #FFECE0;
  294. border-radius: 15rpx;
  295. border: 2rpx solid #FF6702;
  296. }
  297. .go-img {
  298. width: 54rpx;
  299. height: 54rpx;
  300. position: absolute;
  301. right: 0;
  302. top: 0;
  303. }
  304. .item-goods {
  305. display: flex;
  306. flex-direction: column;
  307. gap: 20rpx;
  308. width: 100%;
  309. // height: 100%;
  310. padding: 19rpx 38rpx;
  311. background: #FFFFFF;
  312. border-radius: 23rpx 23rpx 0rpx 0rpx;
  313. }
  314. .good {
  315. display: flex;
  316. align-items: center;
  317. .image {
  318. width: 160rpx;
  319. height: 160rpx;
  320. margin-right: 20rpx;
  321. border-radius: 8rpx;
  322. }
  323. .right {
  324. flex: 1;
  325. // height: 160rpx;
  326. overflow: hidden;
  327. display: flex;
  328. flex-direction: column;
  329. align-items: flex-start;
  330. justify-content: space-between;
  331. padding-right: 14rpx;
  332. .name {
  333. font-size: $font-size-base;
  334. margin-bottom: 10rpx;
  335. }
  336. .tips {
  337. width: 100%;
  338. height: 40rpx;
  339. line-height: 40rpx;
  340. overflow: hidden;
  341. text-overflow: ellipsis;
  342. white-space: nowrap;
  343. font-size: $font-size-sm;
  344. color: $text-color-assist;
  345. margin-bottom: 10rpx;
  346. }
  347. .price_and_action {
  348. width: 100%;
  349. display: flex;
  350. justify-content: space-between;
  351. align-items: center;
  352. .price {
  353. font-size: $font-size-base;
  354. font-weight: 600;
  355. }
  356. }
  357. }
  358. }
  359. .cart-box {
  360. position: absolute;
  361. // bottom: 30rpx;
  362. left: 30rpx;
  363. right: 30rpx;
  364. height: 96rpx;
  365. border-radius: 48rpx;
  366. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.2);
  367. background-color: #000;
  368. display: flex;
  369. align-items: center;
  370. justify-content: space-between;
  371. z-index: 9999;
  372. .cart-img {
  373. width: 50rpx;
  374. height: 47rpx;
  375. position: relative;
  376. // margin-top: -48rpx;
  377. }
  378. .pay-btn {
  379. height: 100%;
  380. padding: 0 30rpx;
  381. color: #FFFFFF;
  382. border-radius: 0 50rpx 50rpx 0;
  383. display: flex;
  384. align-items: center;
  385. font-size: $font-size-base;
  386. }
  387. .price {
  388. flex: 1;
  389. color: $text-color-base;
  390. }
  391. }
  392. .item-con {
  393. display: flex;
  394. justify-content: space-between;
  395. align-items: center;
  396. font-weight: 500;
  397. font-size: 21rpx;
  398. color: #141414;
  399. margin-bottom: 10rpx;
  400. }
  401. .container {
  402. overflow: hidden;
  403. position: relative;
  404. }
  405. .box-txt{
  406. overflow-wrap: break-word;
  407. font-size: 22rpx;
  408. font-family: PingFangSC-Medium;
  409. font-weight: 500;
  410. text-align: left;
  411. white-space: nowrap;
  412. line-height: 40rpx;
  413. }
  414. .boxnamae{
  415. overflow-wrap: break-word;
  416. color: rgba(20, 20, 20, 1);
  417. font-size: 32rpx;
  418. font-family: PingFangSC-Medium;
  419. font-weight: 500;
  420. text-align: center;
  421. white-space: nowrap;
  422. line-height: 44rpx;
  423. }
  424. .remark-txt{
  425. width: 100%;
  426. height: 150rpx;
  427. background: #D6D7DC;
  428. color: #141414;
  429. padding: 20rpx;
  430. box-sizing: border-box;
  431. }
  432. </style>