mine.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <view class="container">
  3. <view class="head-wrap">
  4. <view class="content">
  5. <view class="avatar-wrap">
  6. <u-avatar :src="user_info.avatar" @click="onClickAvatar" size="80"></u-avatar>
  7. </view>
  8. <view class="user-nickname">
  9. <u--text
  10. size="18"
  11. bold
  12. :text="user_info.nickname ? user_info.nickname : 'fadsfdaf'"
  13. ></u--text>
  14. <u--text size="12" text="欢迎加入车旅程"></u--text>
  15. </view>
  16. <view>
  17. <!-- 已登录 -->
  18. <!-- <view class="user-base" v-if="user_info.nickname"> -->
  19. <view class="user-base">
  20. <view class="btn-wrap">
  21. <u-icon
  22. size="30"
  23. @tap="$Router.push('/pages/client/clientUser/setting')"
  24. name="setting"
  25. ></u-icon>
  26. </view>
  27. </view>
  28. <!-- 未登录 -->
  29. <!-- <view class="clickLogin" v-else @tap="$Router.push('/pages/login/index')">
  30. 点击登录/注册
  31. </view> -->
  32. </view>
  33. </view>
  34. <!-- 收藏 -->
  35. <view class="Collect">
  36. <u-grid :border="false" col="4">
  37. <u-grid-item
  38. v-for="(listItem, listIndex) in collectList"
  39. :key="listIndex"
  40. @tap="$Router.push(listItem.url)"
  41. >
  42. <u-icon
  43. :customStyle="{ paddingTop: 20 + 'rpx' }"
  44. :name="listItem.name"
  45. :size="24"
  46. color="#fff"
  47. />
  48. <text class="grid-text">{{ listItem.title }}</text>
  49. </u-grid-item>
  50. </u-grid>
  51. </view>
  52. <view class="order-out-box">
  53. <view class="order-inner-box">
  54. <u-grid :border="false" col="4" style="background-color: #fff">
  55. <u-grid-item
  56. v-for="(listItem, listIndex) in oderList"
  57. :key="listIndex"
  58. @tap="gotoOrder(listItem)"
  59. >
  60. <u-icon
  61. :customStyle="{ paddingTop: 20 + 'rpx' }"
  62. :name="listItem.name"
  63. :size="34"
  64. ></u-icon>
  65. <text class="grid-text">{{ listItem.title }}</text>
  66. </u-grid-item>
  67. </u-grid>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 我的收益 -->
  72. <view class="income-out-box">
  73. <view class="income-inner-box" @click="handlerSkipMyProfit">
  74. <view class="income-head">
  75. <text class="my-income">我的钱包</text>
  76. <u-icon name="arrow-right" />
  77. </view>
  78. <view class="income-content">
  79. <u-grid :border="false" col="4" bgColor="#fff">
  80. <u-grid-item v-for="(listItem, listIndex) in incomeList" :key="listIndex">
  81. <view class="num-box">{{ listItem.num }}元</view>
  82. <view class="num-title">{{ listItem.title }}</view>
  83. </u-grid-item>
  84. </u-grid>
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 预约列表 -->
  89. <view class="appointList">
  90. <u-cell icon="setting-fill" title="预约列表" isLink url="/pages/client/clientUser/appoint" />
  91. <u-cell icon="setting-fill" title="我要开店" isLink />
  92. </view>
  93. <view class="other-out-box">
  94. <view class="other-inner-box">
  95. <u-cell-group :border="false">
  96. <u-cell
  97. v-for="(item, index) in listData"
  98. :key="index"
  99. size="large"
  100. :border="false"
  101. :icon="item.icon"
  102. :title="item.title"
  103. isLink
  104. :url="item.url"
  105. ></u-cell>
  106. </u-cell-group>
  107. </view>
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. import { maintainUserInfo } from '@/api/client/mine.js';
  113. export default {
  114. data() {
  115. return {
  116. collectList: [
  117. {
  118. name: 'photo',
  119. title: '收藏',
  120. url: '/pages/client/clientUser/collectList',
  121. },
  122. {
  123. name: 'lock',
  124. title: '积分',
  125. url: '/pages/client/clientUser/myScore',
  126. },
  127. {
  128. name: 'star',
  129. title: '询价记录',
  130. url: '/pages/client/clientUser/inquiryList',
  131. },
  132. {
  133. name: 'hourglass',
  134. title: '优惠券',
  135. url: '/pages/client/clientUser/coupon',
  136. },
  137. ],
  138. oderList: [
  139. {
  140. name: 'order',
  141. title: '全部订单',
  142. type: 0,
  143. },
  144. {
  145. name: 'bag-fill',
  146. title: '待付款',
  147. type: 1,
  148. },
  149. {
  150. name: 'car-fill',
  151. title: '已付款',
  152. type: 2,
  153. },
  154. {
  155. name: 'heart',
  156. title: '待评价',
  157. type: 3,
  158. },
  159. ],
  160. incomeList: [
  161. {
  162. num: '0.00',
  163. title: '总收益',
  164. },
  165. {
  166. num: '0.00',
  167. title: '本月收益',
  168. },
  169. {
  170. num: '0.00',
  171. title: '本周收益',
  172. },
  173. {
  174. num: '0.00',
  175. title: '可提现',
  176. },
  177. ],
  178. listData: [
  179. {
  180. id: '0',
  181. icon: 'setting-fill',
  182. title: '我的团队',
  183. url: '/pages/client/clientUser/myGroup',
  184. },
  185. {
  186. id: '1',
  187. icon: 'setting-fill',
  188. title: '我要推广',
  189. url: '/pages/client/clientUser/myGroup',
  190. },
  191. {
  192. id: '2',
  193. icon: 'setting-fill',
  194. title: '客服中心',
  195. url: '/pages/client/clientUser/serviceCenter',
  196. },
  197. {
  198. id: '3',
  199. icon: 'setting-fill',
  200. title: '商务合作',
  201. url: '/pages/client/clientUser/serviceCenter',
  202. },
  203. {
  204. id: '4',
  205. icon: 'setting-fill',
  206. title: '意见反馈',
  207. url: '/pages/client/clientUser/serviceCenter',
  208. },
  209. ],
  210. user_info: {}, // 个人信息
  211. avatar: '/pages/static', // 用于存储图片路径
  212. };
  213. },
  214. async mounted() {
  215. await this.handlerInitUserMessage();
  216. },
  217. methods: {
  218. // 获取当前用户信息
  219. handlerInitUserMessage() {
  220. maintainUserInfo().then(res => {
  221. this.user_info = res.data;
  222. });
  223. },
  224. // 点击头像
  225. async onClickAvatar() {
  226. try {
  227. const res = await uni.showActionSheet({
  228. itemList: ['拍照', '从相册选择'],
  229. });
  230. if (res.tapIndex === 0) {
  231. // 用户选择拍照
  232. this.takePhoto();
  233. } else if (res.tapIndex === 1) {
  234. // 用户选择从相册选择
  235. this.chooseImage();
  236. }
  237. } catch (error) {
  238. console.error(error);
  239. }
  240. },
  241. // 拍照
  242. takePhoto() {
  243. uni.chooseImage({
  244. sourceType: ['camera'],
  245. count: 1,
  246. success: res => {
  247. const tempFilePaths = res.tempFilePaths;
  248. // 调用上传图片的方法
  249. this.uploadAvatar(tempFilePaths[0]);
  250. },
  251. fail: error => {
  252. console.error(error);
  253. },
  254. });
  255. },
  256. //从相册中选择
  257. chooseImage() {
  258. uni.chooseImage({
  259. sourceType: ['album'],
  260. count: 1,
  261. success: res => {
  262. const tempFilePaths = res.tempFilePaths;
  263. // 调用上传图片的方法
  264. this.uploadAvatar(tempFilePaths[0]);
  265. },
  266. fail: error => {
  267. console.error(error);
  268. },
  269. });
  270. },
  271. // 上传头像
  272. uploadAvatar(filePath) {
  273. // 在这里实现上传头像的逻辑,将filePath作为参数传入
  274. const newImagePath = api.uploadImage(filePath);
  275. this.user_info.avatar = newImagePath;
  276. this.$forceUpdate(); // 手动触发组件的重新渲染
  277. },
  278. // 点击跳转到全部订单
  279. gotoOrder(item) {
  280. uni.navigateTo({
  281. url: `/pages/client/clientPackage/orderAll?type=${item.type}`,
  282. });
  283. },
  284. // 点击跳转到我的收益
  285. handlerSkipMyProfit() {
  286. uni.navigateTo({
  287. url: '/pages/client/clientUser/myProfit',
  288. });
  289. },
  290. },
  291. };
  292. </script>
  293. <style lang="scss" scoped>
  294. .container {
  295. min-height: 100vh;
  296. background-color: #efefef;
  297. }
  298. /* 顶部登录 */
  299. .head-wrap {
  300. background-color: #c8c9cc;
  301. height: 390rpx;
  302. padding-top: 40rpx;
  303. .content {
  304. display: flex;
  305. justify-content: space-between;
  306. padding: 38rpx 0 0 36rpx;
  307. box-sizing: border-box;
  308. .user-nickname {
  309. margin-left: -215rpx;
  310. margin-top: 50rpx;
  311. }
  312. .clickLogin {
  313. font-size: 48rpx;
  314. color: #ffffff;
  315. margin-top: 40rpx;
  316. margin-left: 20rpx;
  317. }
  318. .avatar-wrap {
  319. display: inline-block;
  320. }
  321. .user-base {
  322. margin-left: 10rpx;
  323. vertical-align: middle;
  324. display: flex;
  325. flex-direction: column;
  326. justify-content: space-evenly;
  327. .btn-wrap {
  328. width: 160rpx;
  329. margin-top: 40rpx;
  330. margin-right: -25rpx;
  331. }
  332. }
  333. }
  334. .Collect {
  335. margin-top: 10rpx;
  336. // 宫格颜色
  337. .grid-text {
  338. font-size: 30rpx;
  339. color: #fff;
  340. margin-top: 5rpx;
  341. box-sizing: border-box;
  342. }
  343. }
  344. .order-out-box {
  345. margin-top: 30rpx;
  346. padding: 10rpx 16rpx;
  347. box-sizing: border-box;
  348. .order-inner-box {
  349. font-size: 30rpx;
  350. padding-bottom: 30rpx;
  351. background-color: $uni-bg-color;
  352. border-radius: 10rpx;
  353. }
  354. }
  355. }
  356. .income-out-box {
  357. margin-top: 110rpx;
  358. padding: 10rpx 16rpx;
  359. box-sizing: border-box;
  360. .income-inner-box {
  361. padding: 20rpx;
  362. background-color: $uni-bg-color;
  363. .income-head {
  364. display: flex;
  365. justify-content: space-between;
  366. .my-income {
  367. color: $uni-color-primary;
  368. font-size: 32rpx;
  369. font-weight: 600;
  370. }
  371. }
  372. .income-content {
  373. .num-box {
  374. padding: 20rpx 0;
  375. font-size: 36rpx;
  376. font-weight: 600;
  377. color: $uni-text-color;
  378. }
  379. .num-title {
  380. font-size: 28rpx;
  381. color: $uni-text-color-grey;
  382. }
  383. }
  384. }
  385. }
  386. .other-out-box {
  387. margin-top: 10rpx;
  388. padding: 20rpx 16rpx;
  389. box-sizing: border-box;
  390. .other-inner-box {
  391. background-color: $uni-bg-color;
  392. }
  393. }
  394. .appointList {
  395. background-color: #fff;
  396. margin: 10rpx 16rpx 0 16rpx;
  397. }
  398. </style>