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

248 lines
7.1 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
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>
  3. <view class="user-header">
  4. <view class="flex flex-between login">
  5. <view class="flex">
  6. <up-image class="mr20" width="120rpx" height="120rpx" :src="userInfo.userImage"
  7. shape="circle"></up-image>
  8. <view>{{getIsLogin()?userInfo.userName:"欢迎来到版宠师"}}</view>
  9. </view>
  10. <view style="width: 140rpx">
  11. <up-button v-if="!getIsLogin()" @click="handleLogin" :customStyle="{borderColor:'#fff'}"
  12. type="primary" text="请登录" shape="circle" color="#FFBF60"></up-button>
  13. <up-button v-else @click="logout" :customStyle="{borderColor:'#fff'}" type="primary" text="退出登录"
  14. shape="circle" color="#FFBF60"></up-button>
  15. </view>
  16. </view>
  17. <view class="header-money">
  18. <view class="header-money-list">
  19. <view class="header-money-item flex flex-evenly">
  20. <view style="text-align: center">
  21. <view class="mb20 flex">
  22. <up-image :show-loading="true" src="https://cdn.catmdogd.com/Work/image/work/icon4.png"
  23. width="68rpx" height="68rpx"></up-image>
  24. 服务酬劳
  25. </view>
  26. <view class="mb20">{{ userInfo.price }}</view>
  27. <view class="flex flex-between but">
  28. <view @click="toWithdrawDeposit">提现</view>
  29. <view>|</view>
  30. <view @click="toRunningWater">明细</view>
  31. </view>
  32. </view>
  33. <view style="text-align: center">
  34. <view class="mb20 flex">
  35. <up-image :show-loading="true" src="https://cdn.catmdogd.com/Work/image/work/icon4.png"
  36. width="68rpx" height="68rpx"></up-image>
  37. 保证金
  38. </view>
  39. <view class="mb20">{{ userInfo.baoPrice }}</view>
  40. <view @click="toBail" class="but">保证金中心</view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="user-container">
  47. <view class="bgf pd4 radius20 mb28">
  48. <view class="mb28 flex flex-between">
  49. <view class="font36">我的宠物</view>
  50. <view @click="toMyPet" style="color: #707070">更多 ></view>
  51. </view>
  52. <view>
  53. <up-button v-if="!getIsLogin()" @click="handleLogin" class="mb20" size="large"
  54. style="width: 600rpx;height: 135rpx;" type="primary" text="登录后管理宠物" shape=""
  55. color="#FFF4E5"></up-button>
  56. <!-- <up-button v-if="getIsLogin()" class="mb20" size="large" style="width: 500rpx" type="primary"
  57. text="请添加您的爱宠" shape="circle"
  58. color="linear-gradient(to right, rgb(255 ,191 ,96 ,1), rgb(255, 51, 186))"></up-button> -->
  59. <view v-if="isLogin" class="cw-box radius20 pd20 flex">
  60. <up-image class="mr20" width="140rpx" style="flex-shrink: 0" height="140rpx"
  61. :src="pet?.headImage" shape="circle"></up-image>
  62. <view style="width: 418rpx">
  63. <view class="font32 mb20">{{ pet.type }}</view>
  64. <view class="font24 ellipsis">澳大利亚雾猫澳洲斑点雾猫| 1 个月</view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="bgf pd40 radius20">
  70. <view class="font36 mb28">服务中心</view>
  71. <view class="flex flex-between font28 flex-wrap">
  72. <view class="icon-list" @click="toNext">
  73. <up-image class="mb20" src="https://cdn.catmdogd.com/Work/image/work/icon1.png" width="68rpx"
  74. height="68rpx"></up-image>
  75. <view>我的评价</view>
  76. </view>
  77. <view @click="platformProtocol" class="icon-list">
  78. <up-image class="mb20" :show-loading="true"
  79. src="https://cdn.catmdogd.com/Work/image/work/icon2.png" width="68rpx"
  80. height="68rpx"></up-image>
  81. <view>平台协议</view>
  82. </view>
  83. <view @click="openCustomerServiceChat" class="icon-list">
  84. <up-image class="mb20" :show-loading="true"
  85. src="https://cdn.catmdogd.com/Work/image/work/icon3.png" width="68rpx"
  86. height="68rpx"></up-image>
  87. <view>联系客服</view>
  88. </view>
  89. <button plain class="btn-share" open-type="share">
  90. <view class="icon-list">
  91. <up-image class="mb20" :show-loading="true"
  92. src="https://t9.baidu.com/it/u=2834693008,3232051400&fm=193" width="68rpx"
  93. height="68rpx"></up-image>
  94. <view>分享好友</view>
  95. </view>
  96. </button>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <up-popup :show="show" @close="close" :round="10">
  102. <view style="padding: 10rpx 20rpx;height: 50vh;overflow-y: scroll;" v-html="content"></view>
  103. </up-popup>
  104. </template>
  105. <script setup>
  106. import {
  107. computed,
  108. onMounted,
  109. ref
  110. } from "vue"
  111. import {
  112. getIsLogin,
  113. getStorage,
  114. getToken,
  115. removeIsLogin
  116. } from "../../utils/auth";
  117. import tab from "../../plugins/tab";
  118. import {
  119. useStore
  120. } from "vuex"
  121. import {
  122. onShow,
  123. onShareAppMessage,
  124. } from "@dcloudio/uni-app"
  125. import {
  126. petList
  127. } from "@/api/pet/index.js"
  128. onShow(() => {
  129. if (!getIsLogin()) {
  130. uni.navigateTo({
  131. url: "/pages/login/index"
  132. })
  133. }
  134. getPetList();
  135. })
  136. onMounted(() => {
  137. content.value = configList.value?.['home-agreement']?.paramValueArea || ""
  138. // 分享好友
  139. onShareAppMessage(() => {
  140. return {
  141. title: configList.value.applet_info.paramValueText, // 分享标题
  142. imageUrl: configList.value.applet_info.paramValueImage, // 分享图片地址,非必须
  143. path: '/pages/workbenchManage/index', // 分享路径
  144. };
  145. })
  146. })
  147. const store = useStore();
  148. const isLogin = ref(false)
  149. const userInfo = computed(() => {
  150. return store.getters.userInfo
  151. })
  152. const configList = computed(() => {
  153. return store.getters.configList;;
  154. })
  155. const pet = ref({})
  156. const show = ref(false)
  157. const content = ref("")
  158. if (getIsLogin() && getToken()) {
  159. userInfo.value = getStorage("userInfo")
  160. isLogin.value = true
  161. }
  162. const handleLogin = () => {
  163. tab.navigateTo('/pages/login/index')
  164. }
  165. const toNext = () => {
  166. uni.navigateTo({
  167. url: "/otherPages/orderTakingManage/evaluate/index"
  168. })
  169. }
  170. const toRunningWater = () => {
  171. uni.navigateTo({
  172. url: "/otherPages/myOrdersManage/transaction/index"
  173. })
  174. }
  175. const getPetList = async () => {
  176. let response = await petList();
  177. pet.value = response?.data[0] || {};
  178. }
  179. const logout = () => {
  180. store.commit("setUserInfo", {});
  181. uni.removeStorageSync("token")
  182. uni.removeStorageSync("baseInfo")
  183. removeIsLogin();
  184. uni.navigateTo({
  185. url: "/pages/login/index"
  186. })
  187. }
  188. // 跳转提现
  189. const toWithdrawDeposit = () => {
  190. uni.navigateTo({
  191. url: "/otherPages/myOrdersManage/withdrawal/index"
  192. })
  193. }
  194. //跳转保证金
  195. const toBail = () => {
  196. uni.navigateTo({
  197. url: "/otherPages/myOrdersManage/bond/index"
  198. })
  199. }
  200. // 跳转我的宠物
  201. const toMyPet = () => {
  202. uni.navigateTo({
  203. url: '/otherPages/userManage/pet/index'
  204. });
  205. }
  206. const close = () => {
  207. show.value = false;
  208. }
  209. const platformProtocol = () => {
  210. show.value = true;
  211. }
  212. // 定义 openCustomerServiceChat 方法,用于唤起客服会话界面
  213. const openCustomerServiceChat = () => {
  214. uni.openCustomerServiceChat({
  215. extInfo: {
  216. url: "https://work.weixin.qq.com/kfid/kfc135d138d063817e1"
  217. },
  218. sessionFrom: '1000',
  219. // 成功回调函数
  220. success: function(res) {
  221. console.log('成功打开客服会话', res);
  222. },
  223. // 失败回调函数
  224. fail: function(err) {
  225. console.error('打开客服会话失败', err);
  226. }
  227. });
  228. };
  229. </script>
  230. <style scoped lang="scss">
  231. @import "index";
  232. </style>