index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view>
  3. <view class="top-1">
  4. <!-- 状态栏高度 -->
  5. <view :style="{ height: `${statusBarHeight}px` }"></view>
  6. <!-- 导航栏 -->
  7. <view :style="{ height: `${navigationBarHeight}px`,lineHeight: `${navigationBarHeight}px`}" class="order-nav">订单
  8. </view>
  9. <!-- 进行中/历史订单 -->
  10. <view class="status-bar">
  11. <view>
  12. <text :class="isShow==0? 'status-true': 'status-false'" @click="statusClick(0)">进行中</text>
  13. <text :class="isShow==1? 'status-true': 'status-false'" @click="statusClick(1)">历史订单</text>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 列表数据 -->
  18. <view class="nbox-1">
  19. <view class="nbox-2" v-for="(item,index) in list" :key="index">
  20. <view class="container">
  21. <text class="left-text">{{item.merName}}</text>
  22. <view class="right-group">
  23. <text v-if="item.status==1||item.status==2||item.status==3" style="color: #0FBA42;font-size: 23rpx;">制作中</text>
  24. <text v-if="item.status==4" style="color: #FF5500;font-size: 23rpx;">待取餐</text>
  25. <image src="/static/img/ic-yx.png" class="image" />
  26. </view>
  27. </view>
  28. <view class="scroll-container" v-for='(ottm,indexs) in item.orderInfoList' :key="indexs">
  29. <view class="item">
  30. <img :src='ottm.image'>
  31. <text>{{ottm.productName}} x{{ottm.payNum}}</text>
  32. </view>
  33. </view>
  34. <view class="dashed-line"></view>
  35. <view style="text-align: right; font-size: 23rpx; color: #141414;padding-right: 20rpx;">
  36. 共{{item.orderInfoList.length}}件,实付 ¥{{ item.payPrice}}元
  37. </view>
  38. <view class="container2">
  39. <text v-if="item.status==1||item.status==2||item.status==3" class="left-text2">商家正在备餐中</text>
  40. <text v-if="item.status==4" class="left-text2">商家备餐完成</text>
  41. <view class="right-group">
  42. <image src="/static/img/ic-iphone1.png" class="image2" />
  43. <text @click="makePhoneCall(item)" style="color: #141414;font-size: 21rpx;">联系商家</text>
  44. <view style="display: inline-block; width: 2rpx; height: 42rpx;border: 2rpx solid #D5D6DC;"></view>
  45. <!-- 留言字段 -->
  46. <image src="/static/img/ic-message1.png" class="image2" />
  47. <text style="color: #141414;font-size: 21rpx;">留言</text>
  48. </view>
  49. </view>
  50. </view>
  51. <view class='loadingicon flex-center' :hidden='!loading'>
  52. <text class='loading iconfont icon-jiazai' style="width: auto;"></text>加载更多
  53. </view>
  54. <view class="flex-center no-data-tip" v-if="loadTitle">{{loadTitle}}</view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. getOrderList
  61. } from '@/api/order.js';
  62. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  63. let app = getApp();
  64. export default {
  65. data() {
  66. return {
  67. statusBarHeight: app.globalData.statusBarHeight,
  68. navigationBarHeight: 0,
  69. isShow: 0,
  70. loading: false,
  71. noDataTip: '',
  72. loadTitle: '',
  73. page: 1,
  74. list: [], //订单数据
  75. }
  76. },
  77. //下拉刷新
  78. onPullDownRefresh() {
  79. },
  80. onLoad(options) {
  81. let that = this;
  82. //首页数据加载
  83. // this.getIndexConfig();
  84. // #ifdef MP-WEIXIN
  85. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  86. const custom = wx.getMenuButtonBoundingClientRect()
  87. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  88. this.navigationBarHeight = custom.height + (custom.top - this.statusBarHeight) * 2
  89. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  90. // #endif
  91. this.getOrderList() //订单列表
  92. },
  93. onShow() {
  94. },
  95. methods: {
  96. // 拨打电话
  97. makePhoneCall(item) {
  98. const phoneNumber = item.merPhone; // 替换为商家的电话号码
  99. uni.makePhoneCall({
  100. phoneNumber: phoneNumber,
  101. success() {
  102. console.log('拨打电话成功');
  103. },
  104. fail() {
  105. console.log('拨打电话失败');
  106. }
  107. });
  108. },
  109. // 头部切换
  110. statusClick(index) {
  111. this.isShow = index;
  112. this.list = []
  113. this.page = 1
  114. this.getOrderList() // 订单列表
  115. },
  116. // 订单列表
  117. getOrderList() {
  118. this.loading = true
  119. getOrderList({
  120. limit: 20, //条数
  121. page: this.page, //页码
  122. orderType: this.isShow, //类型订单类型:0-进行中,1-完成
  123. }).then(res => {
  124. console.log('订单列表', res)
  125. if (res.code == 200) {
  126. const list = res.data.list
  127. this.list = this.$util.SplitArray(list, this.list);
  128. if (this.list.length == 0) {
  129. this.loadTitle = ''
  130. this.noDataTip = ' 暂无外卖商家 ';
  131. } else {
  132. this.noDataTip = ''
  133. this.loadTitle = list.length < 20 ? "我也是有底线的~" : '';
  134. }
  135. this.loading = false
  136. this.page += 1
  137. }
  138. }).catch(err => {
  139. this.loading = false
  140. })
  141. }
  142. },
  143. mounted() {
  144. },
  145. }
  146. </script>
  147. <style scoped>
  148. .order-nav {
  149. font-weight: 500;
  150. font-size: 35rpx;
  151. color: #FFFFFF;
  152. background-color: #FF6702;
  153. text-align: center;
  154. }
  155. .no-data-tip {
  156. color: #CCC;
  157. }
  158. .status-bar {
  159. background-color: #FF6702;
  160. text-align: center;
  161. padding: 20rpx;
  162. box-sizing: border-box;
  163. }
  164. .status-bar view {
  165. display: inline-block;
  166. width: 385rpx;
  167. background: #EB5E00;
  168. border-radius: 37rpx;
  169. }
  170. .status-true {
  171. display: inline-block;
  172. width: 192rpx;
  173. padding: 10rpx 0;
  174. background-color: white;
  175. color: #FF6600;
  176. border-radius: 37rpx;
  177. }
  178. .status-false {
  179. display: inline-block;
  180. width: 192rpx;
  181. padding: 10rpx 0;
  182. color: #FFCBA9;
  183. border-radius: 37rpx;
  184. }
  185. .container {
  186. display: flex;
  187. justify-content: space-between;
  188. align-items: center;
  189. }
  190. .left-text {
  191. font-weight: 600;
  192. font-size: 27rpx;
  193. color: #141414;
  194. margin-left: 40rpx;
  195. }
  196. .right-group {
  197. display: flex;
  198. align-items: center;
  199. gap: 16rpx;
  200. }
  201. .image {
  202. width: 42rpx;
  203. height: 70rpx;
  204. margin-right: 20rpx;
  205. }
  206. .container2 {
  207. display: flex;
  208. justify-content: space-between;
  209. align-items: center;
  210. background-color: #F8F9FB;
  211. margin: 20rpx 20rpx 0 20rpx;
  212. padding: 20rpx 40rpx 20rpx 20rpx;
  213. }
  214. .left-text2 {
  215. font-weight: 600;
  216. color: #141414;
  217. font-size: 23rpx;
  218. margin-left: 0;
  219. }
  220. .image2 {
  221. width: 42rpx;
  222. height: 42rpx;
  223. }
  224. .scroll-container {
  225. display: flex;
  226. overflow-x: auto;
  227. /* 允许水平滚动 */
  228. white-space: nowrap;
  229. /* 防止项目换行 */
  230. padding: 8rpx 20rpx 20rpx 40rpx;
  231. /* 添加一些内边距 */
  232. -webkit-overflow-scrolling: touch;
  233. /* 在iOS上平滑滚动 */
  234. }
  235. .item {
  236. display: inline-flex;
  237. /* 或者使用 flex 但需要调整 */
  238. flex-direction: column;
  239. align-items: center;
  240. margin-right: 20rpx;
  241. /* 项目之间的间距 */
  242. flex: 0 0 auto;
  243. /* 防止项目伸缩 */
  244. }
  245. .item img {
  246. width: 115rpx;
  247. height: 115rpx;
  248. border-radius: 12rpx;
  249. /* 可选:圆形图片 */
  250. object-fit: cover;
  251. /* 保持图片比例 */
  252. }
  253. .item text {
  254. margin-top: 10rpx;
  255. /* 图片和文字之间的间距 */
  256. font-size: 21rpx;
  257. color: #141414;
  258. text-align: center;
  259. white-space: nowrap;
  260. /* 防止文字换行 */
  261. }
  262. .dashed-line {
  263. border-bottom: 2rpx dashed #D6D7DC;
  264. width: 90%;
  265. /* 确保宽度足够 */
  266. height: 2rpx;
  267. /* 控制线条高度 */
  268. margin: 0 40rpx 18rpx 40rpx;
  269. }
  270. .nbox-1 {
  271. padding: 20rpx;
  272. box-sizing: border-box;
  273. display: flex;
  274. flex-direction: column;
  275. gap: 20rpx;
  276. }
  277. .nbox-2 {
  278. background: #FFF;
  279. padding: 15rpx;
  280. box-sizing: border-box;
  281. }
  282. .top-1 {
  283. background-color: #FF6702;
  284. position: sticky;
  285. top: 0;
  286. }
  287. </style>