index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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" @click='goOrderDetails(item)'>
  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" @click='goOrderDetails(item)'>
  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. ProductTypeEnum,
  61. } from "@/enums/productEnums";
  62. import {
  63. getOrderList
  64. } from '@/api/order.js';
  65. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  66. let app = getApp();
  67. export default {
  68. data() {
  69. return {
  70. statusBarHeight: app.globalData.statusBarHeight,
  71. navigationBarHeight: 0,
  72. isShow: 0,
  73. loading: false,
  74. noDataTip: '',
  75. loadTitle: '',
  76. page: 1,
  77. list: [], //订单数据
  78. ProductTypeEnum
  79. }
  80. },
  81. //下拉刷新
  82. onPullDownRefresh() {
  83. },
  84. onLoad(options) {
  85. let that = this;
  86. //首页数据加载
  87. // this.getIndexConfig();
  88. // #ifdef MP-WEIXIN
  89. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  90. const custom = wx.getMenuButtonBoundingClientRect()
  91. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  92. this.navigationBarHeight = custom.height + (custom.top - this.statusBarHeight) * 2
  93. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  94. // #endif
  95. this.getOrderList() //订单列表
  96. },
  97. onShow() {
  98. },
  99. methods: {
  100. /**
  101. * 去订单详情
  102. */
  103. goOrderDetails: function(item, status) {
  104. if (item.groupBuyRecordStatus === 0) return this.$util.Tips({
  105. title: '拼团中无法查看详情'
  106. });
  107. if (!item.orderNo) return this.$util.Tips({
  108. title: '缺少订单号无法查看订单详情'
  109. });
  110. //虚拟商品
  111. if (item.secondType === this.ProductTypeEnum?.CloudDrive || item.secondType === this.ProductTypeEnum
  112. ?.CardPassword) {
  113. // #ifdef MP
  114. uni.navigateTo({
  115. url: '/pages/goods/virtual_order_details/index?orderNo=' + item.orderNo
  116. })
  117. // #endif
  118. } else {
  119. // #ifdef MP
  120. uni.navigateTo({
  121. url: '/pages/goods/order_details/index?orderNo=' + item.orderNo + `&orderType=${this.isShow}`
  122. })
  123. // #endif
  124. }
  125. },
  126. // 拨打电话
  127. makePhoneCall(item) {
  128. const phoneNumber = item.merPhone; // 替换为商家的电话号码
  129. uni.makePhoneCall({
  130. phoneNumber: phoneNumber,
  131. success() {
  132. console.log('拨打电话成功');
  133. },
  134. fail() {
  135. console.log('拨打电话失败');
  136. }
  137. });
  138. },
  139. // 头部切换
  140. statusClick(index) {
  141. this.isShow = index;
  142. this.list = []
  143. this.page = 1
  144. this.getOrderList() // 订单列表
  145. },
  146. // 订单列表
  147. getOrderList() {
  148. this.loading = true
  149. getOrderList({
  150. limit: 20, //条数
  151. page: this.page, //页码
  152. orderType: this.isShow, //类型订单类型:0-进行中,1-完成
  153. }).then(res => {
  154. console.log('订单列表', res)
  155. if (res.code == 200) {
  156. const list = res.data.list
  157. this.list = this.$util.SplitArray(list, this.list);
  158. if (this.list.length == 0) {
  159. this.loadTitle = ''
  160. this.noDataTip = ' 暂无外卖商家 ';
  161. } else {
  162. this.noDataTip = ''
  163. this.loadTitle = list.length < 20 ? "我也是有底线的~" : '';
  164. }
  165. this.loading = false
  166. this.page += 1
  167. }
  168. }).catch(err => {
  169. this.loading = false
  170. })
  171. }
  172. },
  173. mounted() {
  174. },
  175. }
  176. </script>
  177. <style scoped>
  178. .order-nav {
  179. font-weight: 500;
  180. font-size: 35rpx;
  181. color: #FFFFFF;
  182. background-color: #FF6702;
  183. text-align: center;
  184. }
  185. .no-data-tip {
  186. color: #CCC;
  187. }
  188. .status-bar {
  189. background-color: #FF6702;
  190. text-align: center;
  191. padding: 20rpx;
  192. box-sizing: border-box;
  193. }
  194. .status-bar view {
  195. display: inline-block;
  196. width: 385rpx;
  197. background: #EB5E00;
  198. border-radius: 37rpx;
  199. }
  200. .status-true {
  201. display: inline-block;
  202. width: 192rpx;
  203. padding: 10rpx 0;
  204. background-color: white;
  205. color: #FF6600;
  206. border-radius: 37rpx;
  207. }
  208. .status-false {
  209. display: inline-block;
  210. width: 192rpx;
  211. padding: 10rpx 0;
  212. color: #FFCBA9;
  213. border-radius: 37rpx;
  214. }
  215. .container {
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. }
  220. .left-text {
  221. font-weight: 600;
  222. font-size: 27rpx;
  223. color: #141414;
  224. margin-left: 40rpx;
  225. }
  226. .right-group {
  227. display: flex;
  228. align-items: center;
  229. gap: 16rpx;
  230. }
  231. .image {
  232. width: 42rpx;
  233. height: 70rpx;
  234. margin-right: 20rpx;
  235. }
  236. .container2 {
  237. display: flex;
  238. justify-content: space-between;
  239. align-items: center;
  240. background-color: #F8F9FB;
  241. margin: 20rpx 20rpx 0 20rpx;
  242. padding: 20rpx 40rpx 20rpx 20rpx;
  243. }
  244. .left-text2 {
  245. font-weight: 600;
  246. color: #141414;
  247. font-size: 23rpx;
  248. margin-left: 0;
  249. }
  250. .image2 {
  251. width: 42rpx;
  252. height: 42rpx;
  253. }
  254. .scroll-container {
  255. display: flex;
  256. overflow-x: auto;
  257. /* 允许水平滚动 */
  258. white-space: nowrap;
  259. /* 防止项目换行 */
  260. padding: 8rpx 20rpx 20rpx 40rpx;
  261. /* 添加一些内边距 */
  262. -webkit-overflow-scrolling: touch;
  263. /* 在iOS上平滑滚动 */
  264. }
  265. .item {
  266. display: inline-flex;
  267. /* 或者使用 flex 但需要调整 */
  268. flex-direction: column;
  269. align-items: center;
  270. margin-right: 20rpx;
  271. /* 项目之间的间距 */
  272. flex: 0 0 auto;
  273. /* 防止项目伸缩 */
  274. }
  275. .item img {
  276. width: 115rpx;
  277. height: 115rpx;
  278. border-radius: 12rpx;
  279. /* 可选:圆形图片 */
  280. object-fit: cover;
  281. /* 保持图片比例 */
  282. }
  283. .item text {
  284. margin-top: 10rpx;
  285. /* 图片和文字之间的间距 */
  286. font-size: 21rpx;
  287. color: #141414;
  288. text-align: center;
  289. white-space: nowrap;
  290. /* 防止文字换行 */
  291. }
  292. .dashed-line {
  293. border-bottom: 2rpx dashed #D6D7DC;
  294. width: 90%;
  295. /* 确保宽度足够 */
  296. height: 2rpx;
  297. /* 控制线条高度 */
  298. margin: 0 40rpx 18rpx 40rpx;
  299. }
  300. .nbox-1 {
  301. padding: 20rpx;
  302. box-sizing: border-box;
  303. display: flex;
  304. flex-direction: column;
  305. gap: 20rpx;
  306. }
  307. .nbox-2 {
  308. background: #FFF;
  309. padding: 15rpx;
  310. box-sizing: border-box;
  311. }
  312. .top-1 {
  313. background-color: #FF6702;
  314. position: sticky;
  315. top: 0;
  316. }
  317. </style>