index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. getOrderList
  57. } from '@/api/order.js';
  58. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  59. let app = getApp();
  60. export default {
  61. data() {
  62. return {
  63. statusBarHeight: app.globalData.statusBarHeight,
  64. navigationBarHeight: 0,
  65. isShow: 0,
  66. list:[],//订单数据
  67. }
  68. },
  69. //下拉刷新
  70. onPullDownRefresh() {
  71. },
  72. onLoad(options) {
  73. let that = this;
  74. //首页数据加载
  75. // this.getIndexConfig();
  76. // #ifdef MP-WEIXIN
  77. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  78. const custom = wx.getMenuButtonBoundingClientRect()
  79. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  80. this.navigationBarHeight = custom.height + (custom.top - this.statusBarHeight) * 2
  81. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  82. // #endif
  83. this.getOrderList()//订单列表
  84. },
  85. onShow() {
  86. },
  87. methods: {
  88. // 拨打电话
  89. makePhoneCall(item) {
  90. const phoneNumber = item.merPhone; // 替换为商家的电话号码
  91. uni.makePhoneCall({
  92. phoneNumber: phoneNumber,
  93. success() {
  94. console.log('拨打电话成功');
  95. },
  96. fail() {
  97. console.log('拨打电话失败');
  98. }
  99. });
  100. },
  101. // 头部切换
  102. statusClick(index) {
  103. this.isShow = index;
  104. this.getOrderList() // 订单列表
  105. },
  106. // 订单列表
  107. getOrderList(){
  108. getOrderList({
  109. limit:9999,//条数
  110. page:1,//页码
  111. orderType:this.isShow, //类型订单类型:0-进行中,1-完成
  112. }).then(res=>{
  113. console.log('订单列表',res)
  114. if(res.code==200){
  115. this.list=res.data.list
  116. }
  117. })
  118. }
  119. },
  120. mounted() {
  121. },
  122. }
  123. </script>
  124. <style scoped>
  125. .order-nav {
  126. font-weight: 500;
  127. font-size: 35rpx;
  128. color: #FFFFFF;
  129. background-color: #FF6702;
  130. text-align: center;
  131. }
  132. .status-bar {
  133. background-color: #FF6702;
  134. text-align: center;
  135. padding: 20rpx;
  136. box-sizing: border-box;
  137. }
  138. .status-bar view {
  139. display: inline-block;
  140. width: 385rpx;
  141. background: #EB5E00;
  142. border-radius: 37rpx;
  143. }
  144. .status-true {
  145. display: inline-block;
  146. width: 192rpx;
  147. padding: 10rpx 0;
  148. background-color: white;
  149. color: #FF6600;
  150. border-radius: 37rpx;
  151. }
  152. .status-false {
  153. display: inline-block;
  154. width: 192rpx;
  155. padding: 10rpx 0;
  156. color: #FFCBA9;
  157. border-radius: 37rpx;
  158. }
  159. .container {
  160. display: flex;
  161. justify-content: space-between;
  162. align-items: center;
  163. }
  164. .left-text {
  165. font-weight: 600;
  166. font-size: 27rpx;
  167. color: #141414;
  168. margin-left: 40rpx;
  169. }
  170. .right-group {
  171. display: flex;
  172. align-items: center;
  173. gap: 16rpx;
  174. }
  175. .image {
  176. width: 42rpx;
  177. height: 70rpx;
  178. margin-right: 20rpx;
  179. }
  180. .container2 {
  181. display: flex;
  182. justify-content: space-between;
  183. align-items: center;
  184. background-color: #F8F9FB;
  185. margin: 20rpx 20rpx 0 20rpx;
  186. padding: 20rpx 40rpx 20rpx 20rpx;
  187. }
  188. .left-text2 {
  189. font-weight: 600;
  190. color: #141414;
  191. font-size: 23rpx;
  192. margin-left: 0;
  193. }
  194. .image2 {
  195. width: 42rpx;
  196. height: 42rpx;
  197. }
  198. .scroll-container {
  199. display: flex;
  200. overflow-x: auto;
  201. /* 允许水平滚动 */
  202. white-space: nowrap;
  203. /* 防止项目换行 */
  204. padding: 8rpx 20rpx 20rpx 40rpx;
  205. /* 添加一些内边距 */
  206. -webkit-overflow-scrolling: touch;
  207. /* 在iOS上平滑滚动 */
  208. }
  209. .item {
  210. display: inline-flex;
  211. /* 或者使用 flex 但需要调整 */
  212. flex-direction: column;
  213. align-items: center;
  214. margin-right: 20rpx;
  215. /* 项目之间的间距 */
  216. flex: 0 0 auto;
  217. /* 防止项目伸缩 */
  218. }
  219. .item img {
  220. width: 115rpx;
  221. height: 115rpx;
  222. border-radius: 12rpx;
  223. /* 可选:圆形图片 */
  224. object-fit: cover;
  225. /* 保持图片比例 */
  226. }
  227. .item text {
  228. margin-top: 10rpx;
  229. /* 图片和文字之间的间距 */
  230. font-size: 21rpx;
  231. color: #141414;
  232. text-align: center;
  233. white-space: nowrap;
  234. /* 防止文字换行 */
  235. }
  236. .dashed-line {
  237. border-bottom: 2rpx dashed #D6D7DC;
  238. width: 90%;
  239. /* 确保宽度足够 */
  240. height: 2rpx;
  241. /* 控制线条高度 */
  242. margin: 0 40rpx 18rpx 40rpx;
  243. }
  244. .nbox-1{
  245. padding: 20rpx;
  246. box-sizing: border-box;
  247. display: flex;
  248. flex-direction: column;
  249. gap: 20rpx;
  250. }
  251. .nbox-2{
  252. background: #FFF;
  253. padding:15rpx;
  254. box-sizing: border-box;
  255. }
  256. .top-1{
  257. background-color: #FF6702;
  258. position: sticky;
  259. top: 0;
  260. }
  261. </style>