敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

435 lines
9.9 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title=" " bgColor="#019245" color="#fff" />
  5. <!-- 搜索框 -->
  6. <view class="search-box" style="background-color: #fff; padding: 12rpx 20rpx 0rpx; ">
  7. <uv-search placeholder="搜索商品名" v-model="keyword" :showAction="false" actionText="" height="80rpx" animation
  8. bgColor="#F5F5F5" inputAlign="center" color="#000" placeholderColor="#979797"
  9. searchIconSize="50rpx"></uv-search>
  10. </view>
  11. <!-- 订单筛选 -->
  12. <view class="tabs">
  13. <uv-tabs :list="tabs" :activeStyle="{ color: '#019245'}" lineColor="#019245" :scrollable="false"
  14. :inactiveStyle="{color: 'black'}" lineHeight="6rpx" lineWidth="55rpx" :current="current"
  15. @click="clickTabs" />
  16. </view>
  17. <!-- 团餐列表 -->
  18. <view class="group-meal-list">
  19. <view class="meal-item" v-for="(meal, index) in groupMeals" :key="index+meal.id">
  20. <view class="meal-name">{{ meal.name }}</view>
  21. <view class="meal-price">本单佣金合计: <text class="price-value">¥{{meal.price}}</text></view>
  22. <view class="meal-action">
  23. <button class="order-btn" @click="viewOrder(meal)">查看订单</button>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 订单列表 -->
  28. <view class="order-list" v-if="false">
  29. <OrderItem v-for="(order, index) in orderList" :key="order.id" :order="order" @cancel="handleCancelOrder"
  30. @pay="handlePayOrder" @click="goToOrderDetail(order)" />
  31. <view style="
  32. margin-top: 200rpx;
  33. min-width: 700rpx;">
  34. <uv-empty mode="order" v-if="orderList.length == 0"></uv-empty>
  35. </view>
  36. </view>
  37. <!-- <view class="list">
  38. <view class="item" v-for="(item, index) in list" @click="toOrderDetail(item.id)" :key="index">
  39. <view class="content" :key="index" v-for="(good, index) in item.commonOrderSkuList">
  40. <view class="top">
  41. <view class="service">
  42. {{ good.title }}
  43. </view>
  44. <view class="status">
  45. <text> {{ tabs[Number(item.state) + 1].name }}</text>
  46. </view>
  47. </view>
  48. <view class="main">
  49. <view class="left">
  50. <image mode="aspectFill" :src="good.image && good.image.split(',')[0]"></image>
  51. </view>
  52. <view class="right">
  53. <view class="text-hidden-1">
  54. 客户姓名{{item.name}}
  55. </view>
  56. <view class="text-hidden-1">
  57. 下单时间{{item.createTime}}
  58. </view>
  59. <view class="text-hidden-1">
  60. 联系电话{{item.phone}}
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="bottom">
  66. <view class="price">
  67. <text class="total-title">总价格</text>
  68. <text class="unit"></text>
  69. <text class="num">{{item.price}}</text>
  70. <text class="c-unit"></text>
  71. </view>
  72. <view @click.stop="toPayOrder(item)" class="btn" v-if="item.state == 0">
  73. 立即付款
  74. </view>
  75. <view @click.stop="cancelOrder(item)" class="btn" v-if="item.state == 0">
  76. 取消订单
  77. </view>
  78. <view class="btn" @click.stop="confirmOrder(item)" v-if="item.state == 2">
  79. 确认收货
  80. </view>
  81. <view @click.stop="$refs.customerServicePopup.open()" class="btn" v-if="item.state > 0">
  82. 联系客服
  83. </view>
  84. </view>
  85. </view>
  86. <view style="
  87. margin-top: 20rpx;
  88. min-width: 700rpx;">
  89. <uv-empty mode="list" v-if="list.length == 0"></uv-empty>
  90. </view>
  91. </view> -->
  92. <customerServicePopup ref="customerServicePopup" />
  93. <tabber select="order" />
  94. </view>
  95. </template>
  96. <script>
  97. import {
  98. mapGetters
  99. } from 'vuex'
  100. import mixinsList from '@/mixins/list.js'
  101. import mixinsOrder from '@/mixins/order.js'
  102. import tabber from '@/components/base/tabbar.vue'
  103. import customerServicePopup from '@/components/config/customerServicePopup.vue'
  104. import OrderItem from '@/components/order/OrderItem.vue'
  105. import { mockOrders, mockGroupMeals} from '@/static/js/mockOrders.js'
  106. export default {
  107. mixins: [mixinsList, mixinsOrder],
  108. components: {
  109. tabber,
  110. customerServicePopup,
  111. OrderItem
  112. },
  113. computed: {},
  114. data() {
  115. return {
  116. keyword: '',
  117. tabs: [{
  118. name: '待支付'
  119. },
  120. {
  121. name: '待出餐'
  122. },
  123. {
  124. name: '送餐中'
  125. },
  126. {
  127. name: '待取餐'
  128. },
  129. {
  130. name: '已完成'
  131. }
  132. ],
  133. current: 0,
  134. mixinsListApi: 'getOrderPageList',
  135. orderList: [],
  136. groupMeals: []
  137. }
  138. },
  139. onLoad(args) {
  140. this.current = args.type || 0
  141. this.clickTabs({
  142. index: this.current
  143. })
  144. // 加载模拟订单数据
  145. this.loadMockOrders()
  146. this.filterOrdersByStatus(this.current)
  147. },
  148. methods: {
  149. //点击tab栏
  150. clickTabs({
  151. index
  152. }) {
  153. if (index == 0) {
  154. delete this.queryParams.state
  155. } else {
  156. this.queryParams.state = index - 1
  157. }
  158. // 关闭请求
  159. // this.getData()
  160. // 模拟根据状态筛选订单
  161. this.filterOrdersByStatus(index)
  162. },
  163. // 跳转到新订单详情页
  164. goToOrderDetail(order) {
  165. if (order.status === 'completed') {
  166. this.$utils.navigateTo({
  167. url: '/pages_order/order/newOrderDetail?id=' + order.id + '&status=' + order.status
  168. })
  169. } else {
  170. this.$utils.navigateTo({
  171. url: '/pages_order/order/newOrderDetail?id=' + order.id + '&status=' + order.status
  172. })
  173. }
  174. },
  175. // 查看团餐订单
  176. viewOrder(meal) {
  177. this.$utils.navigateTo({
  178. url: '/pages_order/order/groupMealDetail?id=' + meal.id + '&status=' + meal.status
  179. })
  180. },
  181. // 加载模拟订单数据
  182. loadMockOrders() {
  183. this.orderList = mockOrders
  184. this.groupMeals = mockGroupMeals
  185. },
  186. // 根据状态筛选订单
  187. filterOrdersByStatus(index) {
  188. this.loadMockOrders() // 先重置数据
  189. // if (index === 0) return // 全部订单不需要筛选
  190. const statusMap = {
  191. 0: 'pending', // 待支付
  192. 1: 'processing', // 待出餐
  193. 2: 'shipping', // 送餐中
  194. 3: 'delivered', // 待取餐
  195. 4: 'completed' // 已完成
  196. }
  197. const targetStatus = statusMap[index]
  198. if (targetStatus) {
  199. this.orderList = this.orderList.filter(order => order.status === targetStatus)
  200. this.groupMeals = this.groupMeals.filter(meal => meal.status === targetStatus)
  201. }
  202. },
  203. // 处理取消订单
  204. handleCancelOrder(orderId) {
  205. uni.showModal({
  206. title: '提示',
  207. content: '确定要取消订单吗?',
  208. success: (res) => {
  209. if (res.confirm) {
  210. // 模拟取消订单API调用
  211. uni.showToast({
  212. title: '订单已取消',
  213. icon: 'success'
  214. })
  215. // 更新订单状态
  216. const orderIndex = this.orderList.findIndex(item => item.id === orderId)
  217. if (orderIndex !== -1) {
  218. this.orderList[orderIndex].status = 'canceled'
  219. // 如果当前标签页不是全部或已取消,则移除该订单
  220. if (this.current !== 0 && this.current !== 5) {
  221. this.orderList.splice(orderIndex, 1)
  222. }
  223. }
  224. }
  225. }
  226. })
  227. },
  228. // 处理支付订单
  229. handlePayOrder(orderId) {
  230. uni.showToast({
  231. title: '正在跳转支付...',
  232. icon: 'loading'
  233. })
  234. // 模拟支付操作,实际项目中应调用支付API
  235. setTimeout(() => {
  236. uni.hideToast()
  237. uni.showToast({
  238. title: '支付成功',
  239. icon: 'success'
  240. })
  241. // 更新订单状态
  242. const orderIndex = this.orderList.findIndex(item => item.id === orderId)
  243. if (orderIndex !== -1) {
  244. this.orderList[orderIndex].status = 'processing'
  245. // 如果当前标签页不是全部或待发货,则移除该订单
  246. if (this.current !== 0 && this.current !== 2) {
  247. this.orderList.splice(orderIndex, 1)
  248. }
  249. }
  250. }, 1500)
  251. }
  252. }
  253. }
  254. </script>
  255. <style scoped lang="scss">
  256. .page {}
  257. .tabs {
  258. background: #fff;
  259. padding-bottom: 4rpx;
  260. }
  261. .order-list {
  262. padding: 0 20rpx;
  263. // position: relative;
  264. }
  265. /* 团餐列表样式 */
  266. .group-meal-list {
  267. padding: 20rpx;
  268. }
  269. .meal-item {
  270. display: flex;
  271. justify-content: space-between;
  272. align-items: center;
  273. padding: 30rpx 20rpx;
  274. background-color: #fff;
  275. margin-bottom: 20rpx;
  276. border-radius: 10rpx;
  277. }
  278. .meal-info {
  279. flex: 1;
  280. }
  281. .meal-name {
  282. font-size: 32rpx;
  283. font-weight: 500;
  284. margin-bottom: 10rpx;
  285. }
  286. .meal-price {
  287. font-size: 28rpx;
  288. color: $uni-color;
  289. background-color: #ECFEF4;
  290. padding: 10rpx 20rpx;
  291. border-radius: 10rpx;
  292. }
  293. .price-value {
  294. margin-left: 10rpx;
  295. font-weight: 500;
  296. }
  297. .meal-action {
  298. margin-left: 20rpx;
  299. }
  300. .order-btn {
  301. background-color: $uni-color;
  302. color: #fff;
  303. font-size: 28rpx;
  304. padding: 10rpx 30rpx;
  305. border-radius: 30rpx;
  306. line-height: 1.5;
  307. min-width: 160rpx;
  308. }
  309. .list {
  310. .item {
  311. width: calc(100% - 40rpx);
  312. background-color: #fff;
  313. margin: 20rpx;
  314. box-sizing: border-box;
  315. border-radius: 16rpx;
  316. padding: 30rpx;
  317. .content {
  318. .top {
  319. display: flex;
  320. justify-content: space-between;
  321. align-items: center;
  322. font-size: 34rpx;
  323. .status {
  324. font-weight: 600;
  325. color: #FFAC2F;
  326. flex-shrink: 0;
  327. margin-left: 20rpx;
  328. }
  329. }
  330. .main {
  331. display: flex;
  332. margin: 20rpx 0rpx;
  333. .left {
  334. display: flex;
  335. align-items: center;
  336. justify-content: center;
  337. width: 180rpx;
  338. height: 180rpx;
  339. image {
  340. width: 95%;
  341. height: 95%;
  342. border-radius: 10rpx;
  343. }
  344. }
  345. .right {
  346. display: flex;
  347. flex-direction: column;
  348. justify-content: space-between;
  349. width: calc(100% - 200rpx);
  350. color: #777;
  351. font-size: 26rpx;
  352. padding: 30rpx 20rpx;
  353. box-sizing: border-box;
  354. margin-left: 20rpx;
  355. border-radius: 10rpx;
  356. background-color: #F8F8F8;
  357. }
  358. }
  359. }
  360. .bottom {
  361. display: flex;
  362. justify-content: space-between;
  363. font-size: 25rpx;
  364. .price {
  365. .total-title {}
  366. .num {
  367. font-size: 36rpx;
  368. }
  369. .num,
  370. .unit,
  371. .c-unit {
  372. color: $uni-color;
  373. }
  374. }
  375. .btn {
  376. border: 1px solid #C7C7C7;
  377. padding: 10rpx 20rpx;
  378. border-radius: 40rpx;
  379. color: #575757;
  380. }
  381. }
  382. }
  383. }
  384. </style>