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

506 lines
12 KiB

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