index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="container" :style="{ height: winHeight+ 'px' }">
  3. <!-- 状态栏高度 -->
  4. <view :style="{ height: `${statusBarHeight}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">到店自取(15分钟后取餐)</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'>
  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 class="line1"><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>吉啊婆麻辣烫</text>
  41. <view class="good" v-for="(good, key) in goods_list" :key="key">
  42. <image :src="good.images" class="image" @tap="console.log('点击图片')"></image>
  43. <view class="right">
  44. <text class="name">{{ good.name }}</text>
  45. <text class="tips">{{ good.content }}</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. </view>
  74. <!-- 购物车栏 begin -->
  75. <view class="cart-box" :style="{top: (winHeight - 100) + 'px'}">
  76. <view style="margin-left: 39rpx;">
  77. <view style="font-weight: 600;font-size: 27rpx;color: #FFFFFF;" class="price">¥{{ total }}</view>
  78. <text style="font-weight: 400;font-size: 23rpx;color: #999999;">已优惠¥2</text>
  79. </view>
  80. <button type="primary" class="pay-btn bg-color" @tap="toPay">
  81. 去支付
  82. </button>
  83. </view>
  84. <!-- 购物车栏 end -->
  85. </view>
  86. </template>
  87. <script>
  88. import {
  89. getAddressDetail,
  90. getAddressDefault
  91. } from '@/api/user.js';
  92. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  93. let app = getApp();
  94. export default {
  95. data() {
  96. return {
  97. total: 0,
  98. statusBarHeight: app.globalData.statusBarHeight,
  99. navigationBarHeight: 0,
  100. winHeight: 0,
  101. isZhuan: true,
  102. isShow: true,
  103. goIndex: true,
  104. orderNo: '', //预下单订单号
  105. addressInfo: {}, //地址信息
  106. addressId: 0, //地址id
  107. goods_list: [{
  108. id: 11,
  109. name: '土豆片',
  110. content: '月销371',
  111. price: 1,
  112. images: '/static/img/img7.png'
  113. },
  114. {
  115. id: 12,
  116. name: '娃娃菜',
  117. content: '月销371',
  118. price: 2,
  119. images: '/static/img/img7.png'
  120. },
  121. {
  122. id: 13,
  123. name: '方便面',
  124. content: '月销371',
  125. price: 3,
  126. images: '/static/img/img7.png'
  127. }
  128. ],
  129. cart: []
  130. }
  131. },
  132. //下拉刷新
  133. onPullDownRefresh() {
  134. },
  135. onLoad(options) {
  136. let that = this;
  137. uni.getSystemInfo({
  138. success: function(res) {
  139. that.winHeight = res.windowHeight
  140. },
  141. });
  142. //首页数据加载
  143. // this.getIndexConfig();
  144. // #ifdef MP-WEIXIN
  145. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  146. const custom = wx.getMenuButtonBoundingClientRect()
  147. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  148. this.navigationBarHeight = custom.height + (custom.top - this.statusBarHeight) * 2
  149. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  150. // #endif
  151. this.cart = uni.getStorageSync('cart')
  152. this.total = (this.cart.reduce((acc, cur) => acc + cur.number * cur.price, 0)).toFixed(2)
  153. },
  154. onShow() {
  155. },
  156. methods: {
  157. statusClick() {
  158. this.isShow = !this.isShow;
  159. },
  160. toPay() {
  161. // if(!this.isLogin) {
  162. // uni.navigateTo({url: '/pages/login/login'})
  163. // return
  164. // }
  165. },
  166. onAddress: function() {
  167. uni.navigateTo({
  168. url: '/pages/address/user_address_list/index?orderNo=' + this.orderNo
  169. });
  170. },
  171. /*
  172. * 获取默认收货地址或者获取某条地址信息
  173. */
  174. getaddressInfo: function() {
  175. if (this.addressId) {
  176. getAddressDetail(this.addressId).then(res => {
  177. if (res.data) {
  178. res.data.isDefault = res.data.isDefault;
  179. this.addressInfo = res.data || {};
  180. }
  181. })
  182. }
  183. },
  184. },
  185. mounted() {
  186. },
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .bg-color {
  191. background-color: $bg-color-primary;
  192. }
  193. .status-bar {
  194. display: flex;
  195. align-items: center;
  196. justify-content: center;
  197. height: 125rpx;
  198. background-color: #FF6702;
  199. text-align: center;
  200. padding: 20px 0 16rpx 0;
  201. }
  202. .status-bar view {
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. background: #EB5E00;
  207. border-radius: 37rpx;
  208. }
  209. .status-true {
  210. display: inline-block;
  211. width: 326rpx;
  212. padding: 10rpx 0;
  213. background-color: white;
  214. color: #FF6600;
  215. border-radius: 37rpx;
  216. }
  217. .status-false {
  218. display: inline-block;
  219. width: 326rpx;
  220. padding: 10rpx 0;
  221. color: #FFCBA9;
  222. border-radius: 37rpx;
  223. }
  224. .icon-jiantou {
  225. font-size: 26rpx;
  226. color: #515151;
  227. margin-left: 14rpx;
  228. }
  229. .address {
  230. margin-bottom: 40rpx;
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-between;
  234. }
  235. .item-go {
  236. position: relative;
  237. width: 100%;
  238. padding: 20rpx 0;
  239. padding-left: 39rpx;
  240. background: #FFFFFF;
  241. border-radius: 15rpx;
  242. border: 2rpx solid #D6D7DC;
  243. }
  244. .item-go-avt {
  245. position: relative;
  246. color: #FF6702;
  247. background: #FFECE0;
  248. border-radius: 15rpx;
  249. border: 2rpx solid #FF6702;
  250. }
  251. .go-img {
  252. width: 54rpx;
  253. height: 54rpx;
  254. position: absolute;
  255. right: 0;
  256. top: 0;
  257. }
  258. .item-goods {
  259. width: 100%;
  260. height: 100%;
  261. padding: 19rpx 38rpx;
  262. background: #FFFFFF;
  263. border-radius: 23rpx 23rpx 0rpx 0rpx;
  264. }
  265. .good {
  266. display: flex;
  267. align-items: center;
  268. margin-bottom: 30rpx;
  269. .image {
  270. width: 160rpx;
  271. height: 160rpx;
  272. margin-right: 20rpx;
  273. border-radius: 8rpx;
  274. }
  275. .right {
  276. flex: 1;
  277. // height: 160rpx;
  278. overflow: hidden;
  279. display: flex;
  280. flex-direction: column;
  281. align-items: flex-start;
  282. justify-content: space-between;
  283. padding-right: 14rpx;
  284. .name {
  285. font-size: $font-size-base;
  286. margin-bottom: 10rpx;
  287. }
  288. .tips {
  289. width: 100%;
  290. height: 40rpx;
  291. line-height: 40rpx;
  292. overflow: hidden;
  293. text-overflow: ellipsis;
  294. white-space: nowrap;
  295. font-size: $font-size-sm;
  296. color: $text-color-assist;
  297. margin-bottom: 10rpx;
  298. }
  299. .price_and_action {
  300. width: 100%;
  301. display: flex;
  302. justify-content: space-between;
  303. align-items: center;
  304. .price {
  305. font-size: $font-size-base;
  306. font-weight: 600;
  307. }
  308. }
  309. }
  310. }
  311. .cart-box {
  312. position: absolute;
  313. // bottom: 30rpx;
  314. left: 30rpx;
  315. right: 30rpx;
  316. height: 96rpx;
  317. border-radius: 48rpx;
  318. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.2);
  319. background-color: #000;
  320. display: flex;
  321. align-items: center;
  322. justify-content: space-between;
  323. z-index: 9999;
  324. .cart-img {
  325. width: 50rpx;
  326. height: 47rpx;
  327. position: relative;
  328. // margin-top: -48rpx;
  329. }
  330. .pay-btn {
  331. height: 100%;
  332. padding: 0 30rpx;
  333. color: #FFFFFF;
  334. border-radius: 0 50rpx 50rpx 0;
  335. display: flex;
  336. align-items: center;
  337. font-size: $font-size-base;
  338. }
  339. .price {
  340. flex: 1;
  341. color: $text-color-base;
  342. }
  343. }
  344. .item-con {
  345. display: flex;
  346. justify-content: space-between;
  347. align-items: center;
  348. font-weight: 500;
  349. font-size: 21rpx;
  350. color: #141414;
  351. margin-bottom: 10rpx;
  352. }
  353. .container {
  354. overflow: hidden;
  355. position: relative;
  356. }
  357. </style>