敢为人鲜小程序前端代码仓库
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.

505 lines
11 KiB

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