猫妈狗爸伴宠师小程序前端代码
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.

397 lines
11 KiB

4 months ago
4 months ago
4 months ago
4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
2 weeks ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
2 weeks ago
3 months ago
2 weeks ago
4 months ago
3 months ago
  1. <template>
  2. <view>
  3. <view class="user-header">
  4. <view class="flex flex-between login">
  5. <view style="width: 120rpx;">
  6. <up-image class="mr20" width="120rpx" height="120rpx" :src="userInfo.userImage || 'https://image.hhlm1688.com/img/work/log/headImage.png'"
  7. shape="circle"></up-image>
  8. </view>
  9. <view style="width: calc(100% - 120rpx); padding-left: 20rpx;box-sizing: border-box;">
  10. <view class="base-leavel">
  11. <text>{{isLogin ? userInfo.userName : "欢迎来到版宠师"}}</text>
  12. </view>
  13. <view v-if="isLogin">
  14. <image v-if="petMaster" class="role-tag" :src="petMaster" mode="aspectFill"></image>
  15. <image v-if="partnerMaster" class="role-tag" :src="partnerMaster" mode="aspectFill"></image>
  16. </view>
  17. <!-- <view>
  18. 手机号:{{ userInfo?.userTelephone }}
  19. </view> -->
  20. </view>
  21. <!-- <view style="width: 140rpx">
  22. <up-button v-else @click="logout" :customStyle="{borderColor:'#fff'}" type="primary" text="退出登录"
  23. shape="circle" color="#FFBF60"></up-button>
  24. </view> -->
  25. </view>
  26. <view class="header-money">
  27. <view class="header-money-list">
  28. <view class="header-money-item flex flex-evenly">
  29. <view style="text-align: center">
  30. <view class="mb20 flex">
  31. <!-- <up-image :show-loading="true" src="https://cdn.catmdogd.com/Work/image/work/icon4.png"
  32. width="68rpx" height="68rpx"></up-image> -->
  33. <up-image :show-loading="true" src="/static/images/user/a2.png"
  34. style="margin-right: 14rpx;"
  35. width="50rpx" height="50rpx"></up-image>
  36. 服务酬劳
  37. </view>
  38. <view class="mb20">{{ isLogin ? userInfo.price || '0' : '--' }}</view>
  39. <view class="flex flex-between but">
  40. <view @click="handleWithdraw">提现</view>
  41. <view>|</view>
  42. <view @click="handleRunningWater">明细</view>
  43. </view>
  44. </view>
  45. <view style="text-align: center">
  46. <view class="mb20 flex">
  47. <!-- <up-image :show-loading="true" src="https://cdn.catmdogd.com/Work/image/work/icon4.png"
  48. width="68rpx" height="68rpx"></up-image> -->
  49. <up-image :show-loading="true" src="/static/images/user/a1.png"
  50. style="margin-right: 14rpx;"
  51. width="50rpx" height="50rpx"></up-image>
  52. 保证金
  53. </view>
  54. <view class="mb20">{{ isLogin ? userInfo.baoPrice || '0' : '--' }}</view>
  55. <view @click="handleBail" class="but">保证金中心</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="user-container">
  62. <view class="bgf pd4 radius20 mb28">
  63. <view class="mb28 flex flex-between">
  64. <view class="font36">我的爱宠</view>
  65. <view @click="handleMyPet" style="color: #707070">更多 ></view>
  66. </view>
  67. <view>
  68. <view v-if="isLogin && petList.length">
  69. <scroll-view scroll-x class="pet-scroll-container" show-scrollbar="false">
  70. <view class="pet-scroll-content">
  71. <view class="cw-box radius20 pd20 flex pet-item"
  72. v-for="(pet, inde) in petList"
  73. @click="handleEditPet(pet)"
  74. :key="pet.id">
  75. <up-image class="mr20" width="120rpx" style="flex-shrink: 0" height="120rpx"
  76. :src="pet?.headImage" shape="circle"></up-image>
  77. <view style="width: 280rpx">
  78. <view class="font32 mb20 pet-name-container">
  79. {{ pet.nickName }}
  80. <text class="pet-gender" :class="{'pet-gender-male': pet.sex === 0, 'pet-gender-female': pet.sex === 1}">
  81. {{ pet.sex === 0 ? '♂' : '♀' }}
  82. </text>
  83. </view>
  84. <view class="font24 ellipsis">{{ pet.type }} | {{ pet.age }}</view>
  85. </view>
  86. </view>
  87. </view>
  88. </scroll-view>
  89. </view>
  90. <view class="no-pet-tip radius20 pd20 flex" v-else>
  91. <up-image class="mr20" width="80rpx" height="80rpx" src="https://image.hhlm1688.com/img/work/log/headImage.png" shape="circle"></up-image>
  92. <view class="no-pet-text">{{isLogin ? '您还没有添加您的爱宠信息呢' : '登录后查看您的爱宠'}}</view>
  93. <view class="add-pet-btn" @click="handleMyPet">{{isLogin ? '去添加' : '去登录'}}</view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="bgf pd40 radius20">
  98. <view class="font36 mb28">服务中心</view>
  99. <view class="flex flex-between font28 flex-wrap">
  100. <view class="icon-list" @click="handleEvaluate">
  101. <!-- <up-image class="mb20" src="https://cdn.catmdogd.com/Work/image/work/icon1.png" width="68rpx"
  102. height="68rpx"></up-image> -->
  103. <image class="mb20"
  104. src="/static/images/user/1.png"
  105. style="width: 58rpx;height: 58rpx;"
  106. ></image>
  107. <view>我的评价</view>
  108. </view>
  109. <view @click="platformProtocol" class="icon-list">
  110. <!-- <up-image class="mb20" :show-loading="true"
  111. src="https://cdn.catmdogd.com/Work/image/work/icon2.png" width="68rpx"
  112. height="68rpx"></up-image> -->
  113. <image class="mb20"
  114. src="/static/images/user/2.png"
  115. style="width: 58rpx;height: 58rpx;"
  116. ></image>
  117. <view>平台协议</view>
  118. </view>
  119. <button plain class="btn-share" open-type="contact">
  120. <view class="icon-list">
  121. <!-- <up-image class="mb20" :show-loading="true"
  122. src="https://cdn.catmdogd.com/Work/image/work/icon3.png" width="68rpx"
  123. height="68rpx"></up-image> -->
  124. <image class="mb20"
  125. src="/static/images/user/4.png"
  126. style="width: 58rpx;height: 58rpx;"
  127. ></image>
  128. <view>联系客服</view>
  129. </view>
  130. </button>
  131. <button plain class="btn-share" open-type="share">
  132. <view class="icon-list">
  133. <!-- <up-image class="mb20" :show-loading="true"
  134. src="https://t9.baidu.com/it/u=2834693008,3232051400&fm=193" width="68rpx"
  135. height="68rpx"></up-image> -->
  136. <image class="mb20"
  137. src="/static/images/user/5.png"
  138. style="width: 58rpx;height: 58rpx;"
  139. ></image>
  140. <view>分享好友</view>
  141. </view>
  142. </button>
  143. </view>
  144. <!-- <view class="flex flex-between font28 flex-wrap mt20">
  145. <view class="icon-list" @click="logout">
  146. <up-image class="mb20"
  147. src="https://cdn.catmdogd.com/2025/04/01ab556ca51d2a4f82896c1e6fd0034a8b7shDr3f7qeDQ527d93075294e7237cee8b6c7d613be8.png"
  148. width="68rpx" height="68rpx" bgColor="#ffffff"></up-image>
  149. <view>退出登录</view>
  150. </view>
  151. </view> -->
  152. </view>
  153. </view>
  154. </view>
  155. <up-popup :show="show" @close="close" :round="10">
  156. <view style="padding: 10rpx 20rpx;height: 50vh;overflow-y: scroll;" v-html="content"></view>
  157. </up-popup>
  158. <Modal @confirm="confirmLogout" @cancel="cancelLogout" ref="modal">
  159. <template>
  160. <view class="tip">
  161. 确认退出登录?
  162. </view>
  163. </template>
  164. </Modal>
  165. <!-- 客服组件 -->
  166. <CustomerService />
  167. </template>
  168. <script setup>
  169. import {
  170. computed,
  171. onMounted,
  172. ref
  173. } from "vue"
  174. import {
  175. getIsLogin,
  176. getStorage,
  177. getToken,
  178. removeIsLogin
  179. } from "../../utils/auth";
  180. import { getLoginStatus } from "@/utils/useMixin.js"
  181. import tab from "../../plugins/tab";
  182. import Modal from "@/components/Modal/index.vue"
  183. import {
  184. useStore
  185. } from "vuex"
  186. import {
  187. onShow,
  188. onShareAppMessage,
  189. } from "@dcloudio/uni-app"
  190. import {
  191. getpetList
  192. } from "@/api/pet/index.js"
  193. onShow(() => {
  194. checkLoginStatus();
  195. if (isLogin.value) {
  196. getPet();
  197. }
  198. })
  199. onMounted(() => {
  200. content.value = configList.value?.['home_agreement']?.paramValueArea || ""
  201. // 分享好友
  202. onShareAppMessage(() => {
  203. return {
  204. title: configList.value.applet_info.paramValueText, // 分享标题
  205. imageUrl: configList.value.applet_info.paramValueImage, // 分享图片地址,非必须
  206. path: '/pages/workbenchManage/index', // 分享路径
  207. };
  208. })
  209. })
  210. const store = useStore();
  211. const isLogin = ref(false)
  212. const userInfo = computed(() => {
  213. return store.getters.userInfo
  214. })
  215. const configList = computed(() => {
  216. return store.getters.configList;;
  217. })
  218. const petList = ref([])
  219. const show = ref(false)
  220. const content = ref("")
  221. const modal = ref(null)
  222. const LEVEL_AND_KEY_FIELDS_MAPPING = {
  223. '1': 'primary',
  224. '2': 'intermediate',
  225. '3': 'senior',
  226. }
  227. // 按伴宠师等级选中图标
  228. const petMaster = computed(() => {
  229. if (!isLogin.value) return ''
  230. const { userBcs, userBcsRole } = userInfo.value
  231. if (!userBcs) {
  232. return ''
  233. }
  234. const key = `pet_${LEVEL_AND_KEY_FIELDS_MAPPING[userBcsRole]}`
  235. return configList.value?.[key]?.paramValueImage
  236. })
  237. // 按合伙人等级选中图标
  238. const partnerMaster = computed(() => {
  239. if (!isLogin.value) return ''
  240. const { userHh } = userInfo.value
  241. if (!userHh) {
  242. return ''
  243. }
  244. const key = `partner_${LEVEL_AND_KEY_FIELDS_MAPPING[userHh]}`
  245. return configList.value?.[key]?.paramValueImage
  246. })
  247. // 检查登录状态
  248. const checkLoginStatus = () => {
  249. if (getIsLogin() && getToken()) {
  250. isLogin.value = true
  251. } else {
  252. isLogin.value = false
  253. }
  254. }
  255. // 检查登录状态,未登录则跳转登录
  256. const checkLoginAndRedirect = () => {
  257. if (!isLogin.value) {
  258. uni.navigateTo({
  259. url: "/pages/login/index"
  260. })
  261. return false
  262. }
  263. return true
  264. }
  265. // 处理评价点击
  266. const handleEvaluate = () => {
  267. if (!checkLoginAndRedirect()) return
  268. uni.navigateTo({
  269. url: "/otherPages/orderTakingManage/evaluate/index"
  270. })
  271. }
  272. // 处理流水明细点击
  273. const handleRunningWater = () => {
  274. if (!checkLoginAndRedirect()) return
  275. uni.navigateTo({
  276. url: "/otherPages/myOrdersManage/transaction/index"
  277. })
  278. }
  279. // 处理提现点击
  280. const handleWithdraw = () => {
  281. if (!checkLoginAndRedirect()) return
  282. uni.navigateTo({
  283. url: "/otherPages/binding/withdrawal/index?type=1"
  284. })
  285. }
  286. // 处理保证金点击
  287. const handleBail = () => {
  288. if (!checkLoginAndRedirect()) return
  289. uni.navigateTo({
  290. url: "/otherPages/myOrdersManage/bond/index"
  291. })
  292. }
  293. // 处理我的宠物点击
  294. const handleMyPet = () => {
  295. if (!checkLoginAndRedirect()) return
  296. uni.navigateTo({
  297. url: '/otherPages/userManage/pet/index'
  298. });
  299. }
  300. // 处理编辑宠物点击
  301. const handleEditPet = (item) => {
  302. if (!checkLoginAndRedirect()) return
  303. if (item.petType === '猫咪' || item.petType === 0) {
  304. uni.navigateTo({
  305. url: `/otherPages/userManage/pet/petInfo?petType=0&optionType=edit&petId=${item.id}`
  306. })
  307. }
  308. if (item.petType === '狗狗' || item.petType === 1) {
  309. uni.navigateTo({
  310. url: `/otherPages/userManage/pet/petInfo?petType=1&optionType=edit&petId=${item.id}`
  311. })
  312. }
  313. };
  314. const getPet = async () => {
  315. if (!isLogin.value) return;
  316. let response = await getpetList({
  317. userId: userInfo.value.userId
  318. });
  319. petList.value = response?.data || [];
  320. }
  321. const logout = () => {
  322. modal.value.open();
  323. }
  324. const close = () => {
  325. show.value = false;
  326. }
  327. const confirmLogout = () => {
  328. store.commit("setUserInfo", {});
  329. uni.removeStorageSync("token")
  330. uni.removeStorageSync("baseInfo")
  331. removeIsLogin();
  332. uni.navigateTo({
  333. url: "/pages/login/index"
  334. })
  335. }
  336. const platformProtocol = () => {
  337. uni.navigateTo({
  338. url: '/pages/userManage/mine/home_agreement'
  339. })
  340. return
  341. // show.value = true;
  342. }
  343. const cancelLogout = () => {
  344. // 取消退出登录回调
  345. }
  346. </script>
  347. <style scoped lang="scss">
  348. @import "index";
  349. .tip {
  350. text-align: center;
  351. padding-bottom: 20rpx;
  352. }
  353. </style>