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

408 lines
14 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month 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. // 进来加载的时候 会检查一次信息是否完整 若不完整 重新进入登录界面
  208. // 因为是开发模式 取消这个限制
  209. // this.$store.commit('getUserInfo')
  210. uni.setStorageSync('identity', 0) // 一开始的身份默认为团员
  211. this.identity = uni.getStorageSync('identity') // 获取身份
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .center-page {
  217. // min-height: 100vh;
  218. background-color: #f5f5f5;
  219. padding-bottom: 120rpx;
  220. }
  221. .header {
  222. position: relative;
  223. height: 340rpx;
  224. background-size: cover;
  225. background-position: center;
  226. color: #fff;
  227. padding: 60rpx 30rpx 0;
  228. display: flex;
  229. flex-direction: column;
  230. align-items: start;
  231. position: relative;
  232. .user-info {
  233. position: absolute;
  234. display: flex;
  235. align-items: center;
  236. margin-top: 30rpx;
  237. z-index: 2;
  238. left: 30rpx;
  239. top: 120rpx;
  240. .avatar {
  241. width: 110rpx;
  242. height: 110rpx;
  243. border-radius: 50%;
  244. }
  245. .user-name-id {
  246. margin-left: 30rpx;
  247. display: flex;
  248. flex-direction: column;
  249. .user-name {
  250. font-size: 32rpx;
  251. font-weight: bold;
  252. margin-bottom: 6rpx;
  253. }
  254. .user-id {
  255. font-size: 24rpx;
  256. opacity: 0.9;
  257. }
  258. }
  259. }
  260. .role-switch-btn {
  261. position: absolute;
  262. right: 0;
  263. top: 180rpx;
  264. background-color: rgba(255, 255, 255, 0.2);
  265. border-radius: 30rpx 0 0 30rpx;
  266. padding: 10rpx 20rpx;
  267. font-size: 24rpx;
  268. z-index: 2;
  269. display: flex;
  270. align-items: center;
  271. }
  272. }
  273. .orders-section {
  274. background-color: #fff;
  275. border-radius: 20rpx 20rpx 0 0;
  276. margin: -70rpx auto 0;
  277. padding: 15rpx;
  278. position: relative;
  279. z-index: 3;
  280. width: 90%;
  281. // margin: 0 auto;
  282. }
  283. .member-functions {
  284. background-color: #fff;
  285. padding: 30rpx;
  286. margin-top: 20rpx;
  287. width: 88%;
  288. border-radius: 20rpx;
  289. margin: 30rpx auto 0;
  290. }
  291. .section-header {
  292. display: flex;
  293. justify-content: space-between;
  294. align-items: center;
  295. margin-bottom: 40rpx;
  296. .section-title {
  297. font-size: 32rpx;
  298. font-weight: 500;
  299. position: relative;
  300. padding-left: 15rpx;
  301. }
  302. .view-all {
  303. display: flex;
  304. align-items: center;
  305. font-size: 26rpx;
  306. color: $uni-color-third;
  307. }
  308. }
  309. .order-types {
  310. // background-color: red;
  311. display: flex;
  312. justify-content: space-around;
  313. .order-type-item {
  314. display: flex;
  315. flex-direction: column;
  316. align-items: center;
  317. // width: 20%;
  318. .order-icon-wrapper {
  319. position: relative;
  320. margin-bottom: 4rpx;
  321. .green-circle {
  322. width: 70rpx;
  323. height: 70rpx;
  324. background-color: $uni-color;
  325. border-radius: 50%;
  326. display: flex;
  327. justify-content: center;
  328. align-items: center;
  329. }
  330. }
  331. .order-type-text {
  332. font-size: 26rpx;
  333. color: #666;
  334. margin-top: 8rpx;
  335. }
  336. }
  337. }
  338. .function-grid {
  339. display: flex;
  340. flex-wrap: wrap;
  341. .function-item {
  342. width: 25%;
  343. display: flex;
  344. flex-direction: column;
  345. align-items: center;
  346. margin-bottom: 40rpx;
  347. .function-icon {
  348. width: 80rpx;
  349. height: 80rpx;
  350. display: flex;
  351. justify-content: center;
  352. align-items: center;
  353. margin-bottom: 16rpx;
  354. }
  355. .function-text {
  356. font-size: 26rpx;
  357. color: #333;
  358. }
  359. }
  360. }
  361. </style>