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

356 lines
7.3 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
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" 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="status"
  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 leaderOrderList" :key="meal.id">
  20. <view class="meal-name">{{ meal.title }}</view>
  21. <view class="meal-price">本单佣金合计: <text class="price-value">¥{{ (meal.commission || 0).toFixed(2) || 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="leaderOrderList.length == 0" />
  29. </view>
  30. </view>
  31. <!-- 订单列表 -->
  32. <view class="order-list" v-else>
  33. <OrderItem v-for="(order, index) in memberOrderList" :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="memberOrderList.length == 0" />
  38. </view>
  39. </view>
  40. <tabber select="order" />
  41. </view>
  42. </template>
  43. <script>
  44. import mixinsList from '@/mixins/list.js'
  45. import tabber from '@/components/base/tabbar.vue'
  46. import OrderItem from '@/components/order/OrderItem.vue'
  47. export default {
  48. mixins: [mixinsList],
  49. components: {
  50. tabber,
  51. OrderItem
  52. },
  53. computed: {
  54. tabs() {
  55. return this.identity ? this.tabMeal : this.tabOrder
  56. },
  57. },
  58. data() {
  59. return {
  60. keyword: '',
  61. title: '',
  62. tabOrder: [{
  63. name: '待支付'
  64. },
  65. {
  66. name: '待出餐'
  67. },
  68. {
  69. name: '送餐中'
  70. },
  71. {
  72. name: '待取餐'
  73. },
  74. {
  75. name: '已完成'
  76. }
  77. ],
  78. tabMeal: [{
  79. name: '待出餐'
  80. },
  81. {
  82. name: '已出餐'
  83. },
  84. {
  85. name: '待取餐'
  86. },
  87. {
  88. name: '已完成'
  89. }
  90. ],
  91. status: 0,
  92. memberOrderList: [],
  93. leaderOrderList: [],
  94. identity: uni.getStorageSync('identity'),
  95. mixinsListApi: '',
  96. mixinsListKey: '',
  97. }
  98. },
  99. onLoad(args) {
  100. // 这里需要做热更新
  101. this.mixinsListApi = this.identity ? 'queryLeaderOrderList' : 'queryMemberOrderList',
  102. this.mixinsListKey = this.identity ? 'leaderOrderList' : 'memberOrderList'
  103. // 检查是否有tabIndex参数,如果有则自动切换到对应tab
  104. if (args.tabIndex !== undefined) {
  105. const index = parseInt(args.tabIndex)
  106. if (!isNaN(index) && index >= 0 && index < this.tabs.length) {
  107. this.status = index
  108. }
  109. }
  110. },
  111. methods: {
  112. handleSearch() {
  113. this.title = this.keyword
  114. this.getData()
  115. this.keyword = ''
  116. this.title = ''
  117. },
  118. beforeGetData() {
  119. const params = {
  120. status: this.status,
  121. title: this.title || ''
  122. }
  123. return params
  124. },
  125. //点击tab栏
  126. clickTabs({
  127. index
  128. }) {
  129. this.status = index
  130. this.getData()
  131. },
  132. // 跳转到新订单详情页
  133. goToOrderDetail(order) {
  134. this.$utils.navigateTo({
  135. url: '/pages_order/order/newOrderDetail?id=' + order.id
  136. })
  137. },
  138. // 查看团餐订单
  139. viewOrder(meal) {
  140. this.$utils.navigateTo({
  141. url: '/pages_order/order/groupMealDetail?id=' + meal.id
  142. })
  143. },
  144. // // 处理取消订单
  145. handleCancelOrder(orderId) {
  146. uni.showModal({
  147. title: '提示',
  148. content: '确定要取消订单吗?',
  149. confirmColor: '#019245',
  150. success: (res) => {
  151. if (res.confirm) {
  152. // 模拟取消订单API调用
  153. this.$api('deleteMemberOrderById', {
  154. memberOrderId: orderId,
  155. }, res => {
  156. if (res.code == 200){
  157. uni.showToast({
  158. title: '订单已取消',
  159. icon: 'success'
  160. })
  161. this.getData()
  162. }
  163. })
  164. }
  165. }
  166. })
  167. },
  168. // 处理取餐完成
  169. handlePickOrder(orderId) {
  170. uni.showModal( {
  171. title: '提示',
  172. content: '确定取餐完成?',
  173. confirmColor: '#019245',
  174. success: (res) => {
  175. if (res.confirm) {
  176. this.$api('finishMemberOrderById', {
  177. memberOrderId: orderId
  178. }, res => {
  179. if (res.code === 200) {
  180. uni.showToast({
  181. title: '取餐完成',
  182. icon: 'success',
  183. duration: 2000
  184. })
  185. this.getData()
  186. }
  187. })
  188. }
  189. }
  190. })
  191. }
  192. }
  193. }
  194. </script>
  195. <style scoped lang="scss">
  196. .page {}
  197. .tabs {
  198. background: #fff;
  199. padding-bottom: 4rpx;
  200. }
  201. .order-list {
  202. padding: 0 20rpx;
  203. // position: relative;
  204. }
  205. /* 团餐列表样式 */
  206. .group-meal-list {
  207. padding: 20rpx;
  208. }
  209. .meal-item {
  210. display: flex;
  211. justify-content: space-between;
  212. align-items: center;
  213. padding: 30rpx 20rpx;
  214. background-color: #fff;
  215. margin-bottom: 20rpx;
  216. border-radius: 10rpx;
  217. }
  218. .meal-info {
  219. flex: 1;
  220. }
  221. .meal-name {
  222. font-size: 32rpx;
  223. font-weight: 500;
  224. margin-bottom: 10rpx;
  225. }
  226. .meal-price {
  227. font-size: 28rpx;
  228. color: $uni-color;
  229. background-color: #ECFEF4;
  230. padding: 10rpx 20rpx;
  231. border-radius: 10rpx;
  232. }
  233. .price-value {
  234. margin-left: 10rpx;
  235. font-weight: 500;
  236. }
  237. .meal-action {
  238. margin-left: 20rpx;
  239. }
  240. .order-btn {
  241. background-color: $uni-color;
  242. color: #fff;
  243. font-size: 28rpx;
  244. padding: 10rpx 30rpx;
  245. border-radius: 30rpx;
  246. line-height: 1.5;
  247. min-width: 160rpx;
  248. }
  249. .list {
  250. .item {
  251. width: calc(100% - 40rpx);
  252. background-color: #fff;
  253. margin: 20rpx;
  254. box-sizing: border-box;
  255. border-radius: 16rpx;
  256. padding: 30rpx;
  257. .content {
  258. .top {
  259. display: flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. font-size: 34rpx;
  263. .status {
  264. font-weight: 600;
  265. color: #FFAC2F;
  266. flex-shrink: 0;
  267. margin-left: 20rpx;
  268. }
  269. }
  270. .main {
  271. display: flex;
  272. margin: 20rpx 0rpx;
  273. .left {
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. width: 180rpx;
  278. height: 180rpx;
  279. image {
  280. width: 95%;
  281. height: 95%;
  282. border-radius: 10rpx;
  283. }
  284. }
  285. .right {
  286. display: flex;
  287. flex-direction: column;
  288. justify-content: space-between;
  289. width: calc(100% - 200rpx);
  290. color: #777;
  291. font-size: 26rpx;
  292. padding: 30rpx 20rpx;
  293. box-sizing: border-box;
  294. margin-left: 20rpx;
  295. border-radius: 10rpx;
  296. background-color: #F8F8F8;
  297. }
  298. }
  299. }
  300. .bottom {
  301. display: flex;
  302. justify-content: space-between;
  303. font-size: 25rpx;
  304. .price {
  305. .total-title {}
  306. .num {
  307. font-size: 36rpx;
  308. }
  309. .num,
  310. .unit,
  311. .c-unit {
  312. color: $uni-color;
  313. }
  314. }
  315. .btn {
  316. border: 1px solid #C7C7C7;
  317. padding: 10rpx 20rpx;
  318. border-radius: 40rpx;
  319. color: #575757;
  320. }
  321. }
  322. }
  323. }
  324. </style>