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

406 lines
14 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="center-page">
  3. <!-- 顶部背景和个人信息 -->
  4. <view class="header" :style="{ 'background-image': 'url(/static/image/红烧肉.webp)' }">
  5. <view class="user-info">
  6. <image class="avatar" :src="userInfo.avatarUrl" mode="aspectFill"></image>
  7. <view class="user-name-id">
  8. <text class="user-name">{{ userInfo.nickName }}</text>
  9. <text class="user-id">ID:{{ userInfo.userId }}</text>
  10. </view>
  11. </view>
  12. <view class="role-switch-btn" @tap="switchIdentity">
  13. <uv-icon name="reload" size="30rpx" color="#fff" style="margin-right: 6rpx;" />
  14. <text>切换为{{ !identity ? '团长' : '团员'}}</text>
  15. </view>
  16. </view>
  17. <!-- 我的订单区域 -->
  18. <view class="orders-section">
  19. <view class="section-header">
  20. <text class="section-title">我的订单</text>
  21. <view class="view-all" @tap="navigateTo('/pages/index/order?status=all')">
  22. <text>全部</text>
  23. <uv-icon name="arrow-right" size="30rpx" color="#999" />
  24. </view>
  25. </view>
  26. <view class="order-types">
  27. <view class="order-type-item" v-if="identity === 0"
  28. @tap="navigateTo('/pages/index/order?status=pending')">
  29. <view class="order-icon-wrapper">
  30. <view class="green-circle">
  31. <uv-icon name="red-packet" size="44rpx" color="#fff" />
  32. </view>
  33. <uv-badge max="9" absolute :offset="[-10, -12]" bgColor="#FF2A2A"
  34. :value="userInfo.waitingPayCount" style="padding: 10rpx 15rpx;" />
  35. </view>
  36. <text class="order-type-text">待支付</text>
  37. </view>
  38. <view class="order-type-item" @tap="navigateTo('/pages/index/order?status=processing')">
  39. <view class="order-icon-wrapper">
  40. <view class="green-circle">
  41. <uv-icon name="chat" size="44rpx" color="#fff" />
  42. </view>
  43. <uv-badge max="9" absolute :offset="[-10, -12]" bgColor="#FF2A2A"
  44. :value="userInfo.waitingDiningCount" style="padding: 10rpx 15rpx;" />
  45. </view>
  46. <text class="order-type-text">待出餐</text>
  47. </view>
  48. <view class="order-type-item" @tap="navigateTo('/pages/index/order?status=shipping')">
  49. <view class="order-icon-wrapper">
  50. <view class="green-circle">
  51. <uv-icon name="chat" size="44rpx" color="#fff" />
  52. </view>
  53. <uv-badge max="9" absolute :offset="[-10, -12]" bgColor="#FF2A2A"
  54. :value="userInfo.deliveringCount" style="padding: 10rpx 15rpx;" />
  55. </view>
  56. <text class="order-type-text">送餐中</text>
  57. </view>
  58. <view class="order-type-item" @tap="navigateTo('/pages/index/order?status=delivered')">
  59. <view class="order-icon-wrapper">
  60. <view class="green-circle">
  61. <uv-icon name="chat" size="44rpx" color="#fff" />
  62. </view>
  63. <uv-badge max="9" absolute :offset="[-10, -12]" bgColor="#FF2A2A" :value="userInfo.pickupCount"
  64. style="padding: 10rpx 15rpx;" />
  65. </view>
  66. <text class="order-type-text">待取餐</text>
  67. </view>
  68. <view class="order-type-item" @tap="navigateTo('/pages/index/order?status=completed')">
  69. <view class="order-icon-wrapper">
  70. <view class="green-circle">
  71. <uv-icon name="chat" size="44rpx" color="#fff" />
  72. </view>
  73. <uv-badge max="9" absolute :offset="[-10, -12]" bgColor="#FF2A2A"
  74. :value="userInfo.completedCount" style="padding: 10rpx 15rpx;" />
  75. </view>
  76. <text class="order-type-text">已完成</text>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 团员功能区域 -->
  81. <view class="member-functions">
  82. <view class="section-header">
  83. <text class="section-title">团员功能</text>
  84. </view>
  85. <view class="function-grid" v-if="identity === 0">
  86. <view class="function-item" @tap="navigateTo('/pages_order/mine/updateUser')">
  87. <view class="function-icon">
  88. <uv-icon name="chat" size="94rpx" color="#019245" />
  89. </view>
  90. <text class="function-text">资料修改</text>
  91. </view>
  92. <view class="function-item" @tap="navigateTo('/pages_order/mine/team')">
  93. <view class="function-icon">
  94. <uv-icon name="chat" size="94rpx" color="#019245" />
  95. </view>
  96. <text class="function-text">团长申请</text>
  97. </view>
  98. <view class="function-item" @tap="navigateTo('/pages_order/mine/unbindTeam')">
  99. <view class="function-icon">
  100. <uv-icon name="chat" size="94rpx" color="#019245" />
  101. </view>
  102. <text class="function-text">解绑团长</text>
  103. </view>
  104. <view class="function-item" @tap="navigateTo('/pages_order/mine/share')">
  105. <view class="function-icon">
  106. <uv-icon name="chat" size="94rpx" color="#019245" />
  107. </view>
  108. <text class="function-text">推广链接</text>
  109. </view>
  110. <view class="function-item" @tap="navigateTo('/pages_order/mine/coupon')">
  111. <view class="function-icon">
  112. <uv-icon name="chat" size="94rpx" color="#019245" />
  113. </view>
  114. <text class="function-text">优惠券</text>
  115. </view>
  116. <view class="function-item" @tap="navigateTo('/pages_order/mine/wallet')">
  117. <view class="function-icon">
  118. <uv-icon name="chat" size="94rpx" color="#019245" />
  119. </view>
  120. <text class="function-text">钱包</text>
  121. </view>
  122. </view>
  123. <view class="function-grid" v-else>
  124. <view class="function-item" @tap="navigateTo('/pages_order/mine/updateUser')">
  125. <view class="function-icon">
  126. <uv-icon name="chat" size="94rpx" color="#019245" />
  127. </view>
  128. <text class="function-text">我的资料</text>
  129. </view>
  130. <view class="function-item" @tap="navigateTo('/pages_order/mine/myTeam')">
  131. <view class="function-icon">
  132. <uv-icon name="chat" size="94rpx" color="#019245" />
  133. </view>
  134. <text class="function-text">我的团员</text>
  135. </view>
  136. <view class="function-item" @tap="navigateTo('/pages_order/mine/team')">
  137. <view class="function-icon">
  138. <uv-icon name="chat" size="94rpx" color="#019245" />
  139. </view>
  140. <text class="function-text">团长信息</text>
  141. </view>
  142. <view class="function-item" @tap="navigateTo('/pages_order/mine/share')">
  143. <view class="function-icon">
  144. <uv-icon name="chat" size="94rpx" color="#019245" />
  145. </view>
  146. <text class="function-text">推广链接</text>
  147. </view>
  148. <view class="function-item" @tap="navigateTo('/pages_order/mine/wallet')">
  149. <view class="function-icon">
  150. <uv-icon name="chat" size="94rpx" color="#019245" />
  151. </view>
  152. <text class="function-text">钱包</text>
  153. </view>
  154. </view>
  155. </view>
  156. <tabber select="center" />
  157. </view>
  158. </template>
  159. <script>
  160. import tabber from '@/components/base/tabbar.vue'
  161. import { mockUserInfo } from '@/static/js/mockUserInfo.js'
  162. // import { unix } from 'dayjs'
  163. export default {
  164. components: {
  165. tabber
  166. },
  167. data() {
  168. return {
  169. userInfo: mockUserInfo,
  170. identity: 0
  171. }
  172. },
  173. methods: {
  174. navigateTo(url) {
  175. this.$utils.navigateTo({
  176. url
  177. })
  178. },
  179. switchIdentity() {
  180. uni.showModal({
  181. title: '提示',
  182. content: `确定要切换为${this.identity === 0 ? '团长' : '团员'}吗?`,
  183. confirmColor: '#019245',
  184. // cancelColor: '#FF2A2A',
  185. success: (res) => {
  186. if (res.confirm){
  187. // 这里的切换逻辑
  188. uni.showLoading({
  189. title: '切换中...'
  190. })
  191. setTimeout(() => {
  192. uni.hideLoading();
  193. this.identity = this.identity === 0 ? 1 : 0;
  194. uni.setStorageSync('identity', this.identity)
  195. uni.showToast({
  196. title: '切换成功',
  197. icon: 'success',
  198. duration: 2000
  199. })
  200. }, 1000);
  201. }
  202. }
  203. })
  204. }
  205. },
  206. onLoad (){
  207. this.$store.commit('getUserInfo')
  208. uni.setStorageSync('identity', 0) // 一开始的身份默认为团员
  209. this.identity = uni.getStorageSync('identity') // 获取身份
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. .center-page {
  215. // min-height: 100vh;
  216. background-color: #f5f5f5;
  217. padding-bottom: 120rpx;
  218. }
  219. .header {
  220. position: relative;
  221. height: 340rpx;
  222. background-size: cover;
  223. background-position: center;
  224. color: #fff;
  225. padding: 60rpx 30rpx 0;
  226. display: flex;
  227. flex-direction: column;
  228. align-items: start;
  229. position: relative;
  230. .user-info {
  231. position: absolute;
  232. display: flex;
  233. align-items: center;
  234. margin-top: 30rpx;
  235. z-index: 2;
  236. left: 30rpx;
  237. top: 120rpx;
  238. .avatar {
  239. width: 110rpx;
  240. height: 110rpx;
  241. border-radius: 50%;
  242. }
  243. .user-name-id {
  244. margin-left: 30rpx;
  245. display: flex;
  246. flex-direction: column;
  247. .user-name {
  248. font-size: 32rpx;
  249. font-weight: bold;
  250. margin-bottom: 6rpx;
  251. }
  252. .user-id {
  253. font-size: 24rpx;
  254. opacity: 0.9;
  255. }
  256. }
  257. }
  258. .role-switch-btn {
  259. position: absolute;
  260. right: 0;
  261. top: 180rpx;
  262. background-color: rgba(255, 255, 255, 0.2);
  263. border-radius: 30rpx 0 0 30rpx;
  264. padding: 10rpx 20rpx;
  265. font-size: 24rpx;
  266. z-index: 2;
  267. display: flex;
  268. align-items: center;
  269. }
  270. }
  271. .orders-section {
  272. background-color: #fff;
  273. border-radius: 20rpx 20rpx 0 0;
  274. margin: -70rpx auto 0;
  275. padding: 15rpx;
  276. position: relative;
  277. z-index: 3;
  278. width: 90%;
  279. // margin: 0 auto;
  280. }
  281. .member-functions {
  282. background-color: #fff;
  283. padding: 30rpx;
  284. margin-top: 20rpx;
  285. width: 88%;
  286. border-radius: 20rpx;
  287. margin: 30rpx auto 0;
  288. }
  289. .section-header {
  290. display: flex;
  291. justify-content: space-between;
  292. align-items: center;
  293. margin-bottom: 40rpx;
  294. .section-title {
  295. font-size: 32rpx;
  296. font-weight: 500;
  297. position: relative;
  298. padding-left: 15rpx;
  299. }
  300. .view-all {
  301. display: flex;
  302. align-items: center;
  303. font-size: 26rpx;
  304. color: $uni-color-third;
  305. }
  306. }
  307. .order-types {
  308. // background-color: red;
  309. display: flex;
  310. justify-content: space-around;
  311. .order-type-item {
  312. display: flex;
  313. flex-direction: column;
  314. align-items: center;
  315. // width: 20%;
  316. .order-icon-wrapper {
  317. position: relative;
  318. margin-bottom: 4rpx;
  319. .green-circle {
  320. width: 70rpx;
  321. height: 70rpx;
  322. background-color: $uni-color;
  323. border-radius: 50%;
  324. display: flex;
  325. justify-content: center;
  326. align-items: center;
  327. }
  328. }
  329. .order-type-text {
  330. font-size: 26rpx;
  331. color: #666;
  332. margin-top: 8rpx;
  333. }
  334. }
  335. }
  336. .function-grid {
  337. display: flex;
  338. flex-wrap: wrap;
  339. .function-item {
  340. width: 25%;
  341. display: flex;
  342. flex-direction: column;
  343. align-items: center;
  344. margin-bottom: 40rpx;
  345. .function-icon {
  346. width: 80rpx;
  347. height: 80rpx;
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. margin-bottom: 16rpx;
  352. }
  353. .function-text {
  354. font-size: 26rpx;
  355. color: #333;
  356. }
  357. }
  358. }
  359. </style>