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

275 lines
8.1 KiB

  1. <template>
  2. <view class="member-wrapper">
  3. <!-- 成员基本信息 -->
  4. <view class="member-item">
  5. <view class="member-avatar">
  6. <image :src="member.avatar" mode="aspectFill" />
  7. </view>
  8. <view class="member-info">
  9. <text class="member-name">{{ member.name }}</text>
  10. </view>
  11. <view class="check-food-btn check-btn" @click="toggleExpand">
  12. <text>{{ isExpanded ? '收起餐点' : '查看餐点' }}</text>
  13. <uv-icon :name="isExpanded ? 'arrow-up' : 'arrow-down'" color="#019245" size="30rpx"></uv-icon>
  14. </view>
  15. <view v-if="status === 'shipping'" class="check-notice-btn check-btn" @click="sendNotice">
  16. <text>通知取餐</text>
  17. </view>
  18. <view v-if="status === 'delivered'" class="check-notice-btn check-btn" @click="completeSend">
  19. <text>完成取餐</text>
  20. </view>
  21. </view>
  22. <!-- 餐点列表展开区域 - 使用v-if替代uv-transition -->
  23. <view class="food-detail" v-if="isExpanded">
  24. <view class="food-list">
  25. <view class="food-item" v-for="(food, index) in member.food" :key="index">
  26. <view class="food-left">
  27. <image class="food-image" :src="food.image" mode="aspectFill" />
  28. <view class="food-info">
  29. <text class="food-name">{{ food.name }}</text>
  30. <view class="food-sold">
  31. <uv-icon name="checkmark-circle" color="#ccc" size="24rpx"></uv-icon>
  32. <text>已售出 {{ food.sold }}</text>
  33. </view>
  34. <text class="food-price"> <text style="font-size: 20rpx; margin-right: 5rpx;">¥</text> {{ food.price.toFixed(1) }}</text>
  35. </view>
  36. </view>
  37. <view class="food-right">
  38. <text class="food-quantity">×{{ food.quantity }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. name: 'MemberFoodItem',
  48. props: {
  49. // 成员信息,包含头像、姓名和餐点列表
  50. member: {
  51. type: Object,
  52. required: true
  53. },
  54. // 是否默认展开
  55. defaultExpanded: {
  56. type: Boolean,
  57. default: false
  58. },
  59. // 从父页面获取的订单状态
  60. status: {
  61. type: String,
  62. default: 'processing'
  63. }
  64. },
  65. data() {
  66. return {
  67. isExpanded: false
  68. }
  69. },
  70. created() {
  71. // 初始化展开状态
  72. this.isExpanded = this.defaultExpanded;
  73. },
  74. methods: {
  75. // 切换展开/收起状态
  76. toggleExpand() {
  77. this.isExpanded = !this.isExpanded;
  78. // 触发事件,通知父组件状态变化
  79. this.$emit('toggle', {
  80. member: this.member,
  81. expanded: this.isExpanded
  82. });
  83. },
  84. sendNotice() {
  85. // 模拟通知体验
  86. setTimeout(() => {
  87. uni.showLoading({
  88. title: '通知中...',
  89. icon: 'loading',
  90. duration: 2000
  91. })
  92. setTimeout(() => {
  93. uni.hideLoading()
  94. uni.showToast({
  95. title: '通知成功',
  96. icon: 'success',
  97. duration: 2000
  98. })
  99. }, 1200)
  100. }, 200)
  101. // 这里存放通知函数的逻辑....
  102. },
  103. completeSend() {
  104. // 模拟体验
  105. setTimeout(() => {
  106. uni.showLoading({
  107. title: '请稍等...',
  108. icon: 'loading',
  109. duration: 2000
  110. })
  111. setTimeout(() => {
  112. uni.hideLoading()
  113. uni.showToast({
  114. title: '已完成',
  115. icon: 'success',
  116. duration: 2000
  117. })
  118. }, 1200)
  119. }, 200)
  120. // 这里执行函数逻辑
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .member-wrapper {
  127. margin-bottom: 20rpx;
  128. border-radius: 10rpx;
  129. overflow: hidden;
  130. .member-item {
  131. display: flex;
  132. align-items: center;
  133. background-color: #fff;
  134. padding: 30rpx 20rpx;
  135. .member-avatar {
  136. width: 70rpx;
  137. height: 70rpx;
  138. margin-right: 20rpx;
  139. image {
  140. width: 100%;
  141. height: 100%;
  142. border-radius: 10rpx;
  143. }
  144. }
  145. .member-info {
  146. flex: 1;
  147. .member-name {
  148. font-size: 30rpx;
  149. font-weight: 500;
  150. }
  151. }
  152. .check-btn{
  153. border-radius: 30rpx;
  154. display: flex;
  155. align-items: center;
  156. font-size: 26rpx;
  157. gap: 10rpx;
  158. transition: all 0.3s;
  159. &:active {
  160. opacity: 0.8;
  161. transform: scale(0.98);
  162. }
  163. }
  164. .check-food-btn {
  165. border: 2rpx solid $uni-color;
  166. color: $uni-color;
  167. padding: 10rpx 20rpx;
  168. }
  169. .check-notice-btn{
  170. padding: 10rpx 40rpx;
  171. background-color: $uni-color;
  172. color: #fff;
  173. margin-left: 20rpx;
  174. }
  175. }
  176. .food-detail {
  177. background-color: #fff;
  178. padding: 20rpx;
  179. box-shadow: inset 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
  180. .fold-handle {
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. padding: 10rpx 0;
  185. margin-bottom: 10rpx;
  186. border-bottom: 1px dashed #eeeeee;
  187. .fold-text {
  188. font-size: 24rpx;
  189. color: $uni-color-third;
  190. margin-left: 10rpx;
  191. }
  192. &:active {
  193. opacity: 0.8;
  194. }
  195. }
  196. .food-list {
  197. .food-item {
  198. display: flex;
  199. justify-content: space-between;
  200. align-items: center;
  201. padding: 15rpx 0;
  202. border-bottom: 1px solid #f5f5f5;
  203. &:last-child {
  204. border-bottom: none;
  205. }
  206. .food-left {
  207. display: flex;
  208. align-items: center;
  209. .food-image {
  210. width: 120rpx;
  211. height: 120rpx;
  212. // border-radius: 8rpx;
  213. margin-right: 15rpx;
  214. }
  215. .food-info {
  216. .food-name {
  217. font-size: 28rpx;
  218. color: #333;
  219. margin-bottom: 10rpx;
  220. display: block;
  221. }
  222. .food-sold {
  223. display: flex;
  224. align-items: center;
  225. font-size: 24rpx;
  226. color: $uni-color-third;
  227. text {
  228. margin-left: 4rpx;
  229. }
  230. }
  231. .food-price {
  232. font-size: 28rpx;
  233. color: $uni-color-second;
  234. display: block;
  235. margin-bottom: 10rpx;
  236. }
  237. }
  238. }
  239. .food-right {
  240. text-align: right;
  241. .food-quantity {
  242. font-size: 24rpx;
  243. color: #333;
  244. display: block;
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251. </style>