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

277 lines
8.3 KiB

  1. <template>
  2. <view class="member-wrapper">
  3. <!-- 成员基本信息 -->
  4. <view class="member-item">
  5. <view class="member-avatar">
  6. <image :src="member.hanHaiMember.headImage" mode="aspectFill" />
  7. </view>
  8. <view class="member-info">
  9. <text class="member-name">{{ member.hanHaiMember.nickName }}</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 === '1'" class="check-notice-btn check-btn" @click="sendNotice">
  16. <text>通知取餐</text>
  17. </view>
  18. <view v-if="status === '2'" class="check-notice-btn check-btn" @click="completeOrder">
  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.goodsList" :key="index">
  26. <view class="food-left">
  27. <image class="food-image" :src="food.goods.image" mode="aspectFill" />
  28. <view class="food-info">
  29. <text class="food-name">{{ food.goods.title }}</text>
  30. <view class="food-sold">
  31. <uv-icon name="checkmark-circle" color="#ccc" size="24rpx"></uv-icon>
  32. <text>已售出 {{ food.goods.sales }}</text>
  33. </view>
  34. <text class="food-price"> <text style="font-size: 20rpx; margin-right: 5rpx;">¥</text> {{ food.goods.price.toFixed(2) }}</text>
  35. </view>
  36. </view>
  37. <view class="food-right">
  38. <text class="food-quantity">×{{ food.num }}</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: '0'
  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. this.$emit('sendNotice')
  86. // 模拟通知体验
  87. // setTimeout(() => {
  88. // uni.showLoading({
  89. // title: '通知中...',
  90. // icon: 'loading',
  91. // duration: 2000
  92. // })
  93. // setTimeout(() => {
  94. // uni.hideLoading()
  95. // uni.showToast({
  96. // title: '通知成功',
  97. // icon: 'success',
  98. // duration: 2000
  99. // })
  100. // }, 1200)
  101. // }, 200)
  102. // 这里存放通知函数的逻辑....
  103. },
  104. completeOrder() {
  105. this.$emit('completeOrder')
  106. // 模拟体验
  107. // setTimeout(() => {
  108. // uni.showLoading({
  109. // title: '请稍等...',
  110. // icon: 'loading',
  111. // duration: 2000
  112. // })
  113. // setTimeout(() => {
  114. // uni.hideLoading()
  115. // uni.showToast({
  116. // title: '已完成',
  117. // icon: 'success',
  118. // duration: 2000
  119. // })
  120. // }, 1200)
  121. // }, 200)
  122. // 这里执行函数逻辑
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .member-wrapper {
  129. margin-bottom: 20rpx;
  130. border-radius: 10rpx;
  131. overflow: hidden;
  132. .member-item {
  133. display: flex;
  134. align-items: center;
  135. background-color: #fff;
  136. padding: 30rpx 20rpx;
  137. .member-avatar {
  138. width: 70rpx;
  139. height: 70rpx;
  140. margin-right: 20rpx;
  141. image {
  142. width: 100%;
  143. height: 100%;
  144. border-radius: 10rpx;
  145. }
  146. }
  147. .member-info {
  148. flex: 1;
  149. .member-name {
  150. font-size: 30rpx;
  151. font-weight: 500;
  152. }
  153. }
  154. .check-btn{
  155. border-radius: 30rpx;
  156. display: flex;
  157. align-items: center;
  158. font-size: 26rpx;
  159. gap: 10rpx;
  160. transition: all 0.3s;
  161. &:active {
  162. opacity: 0.8;
  163. transform: scale(0.98);
  164. }
  165. }
  166. .check-food-btn {
  167. border: 2rpx solid $uni-color;
  168. color: $uni-color;
  169. padding: 10rpx 20rpx;
  170. }
  171. .check-notice-btn{
  172. padding: 10rpx 40rpx;
  173. background-color: $uni-color;
  174. color: #fff;
  175. margin-left: 20rpx;
  176. }
  177. }
  178. .food-detail {
  179. background-color: #fff;
  180. padding: 20rpx;
  181. box-shadow: inset 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
  182. .fold-handle {
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. padding: 10rpx 0;
  187. margin-bottom: 10rpx;
  188. border-bottom: 1px dashed #eeeeee;
  189. .fold-text {
  190. font-size: 24rpx;
  191. color: $uni-color-third;
  192. margin-left: 10rpx;
  193. }
  194. &:active {
  195. opacity: 0.8;
  196. }
  197. }
  198. .food-list {
  199. .food-item {
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. padding: 15rpx 0;
  204. border-bottom: 1px solid #f5f5f5;
  205. &:last-child {
  206. border-bottom: none;
  207. }
  208. .food-left {
  209. display: flex;
  210. align-items: center;
  211. .food-image {
  212. width: 120rpx;
  213. height: 120rpx;
  214. // border-radius: 8rpx;
  215. margin-right: 15rpx;
  216. }
  217. .food-info {
  218. .food-name {
  219. font-size: 28rpx;
  220. color: #333;
  221. margin-bottom: 10rpx;
  222. display: block;
  223. }
  224. .food-sold {
  225. display: flex;
  226. align-items: center;
  227. font-size: 24rpx;
  228. color: $uni-color-third;
  229. text {
  230. margin-left: 4rpx;
  231. }
  232. }
  233. .food-price {
  234. font-size: 28rpx;
  235. color: $uni-color-second;
  236. display: block;
  237. margin-bottom: 10rpx;
  238. }
  239. }
  240. }
  241. .food-right {
  242. text-align: right;
  243. .food-quantity {
  244. font-size: 24rpx;
  245. color: #333;
  246. display: block;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>