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

191 lines
4.0 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
5 months ago
2 months ago
5 months ago
5 months ago
5 months ago
6 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
5 months ago
5 months ago
6 months ago
5 months ago
5 months ago
6 months ago
5 months ago
  1. <template>
  2. <view class="login">
  3. <view class="login-logo">
  4. <image class="logo" :src="configList?.applet_info?.paramValueImage" mode="aspectFill"></image>
  5. <image class="d" :src="configList?.logo_icon?.paramValueImage" mode="aspectFill"></image>
  6. </view>
  7. <view class="login-submit">
  8. <up-button class="mt24" type="primary" text="授权登陆" @click="loginWx" shape="circle"
  9. color="#FFBF60"></up-button>
  10. </view>
  11. <view class="flex-rowc">
  12. <view>
  13. <up-checkbox
  14. v-model:checked="isAgree"
  15. size="29rpx"
  16. icon-size="29rpx"
  17. name="agree"
  18. usedAlone
  19. shape="circle"
  20. activeColor="#FFBF60"
  21. >
  22. </up-checkbox>
  23. </view>
  24. <view class="size-26 agreement">
  25. <text>我已阅读并同意猫爸狗妈</text>
  26. <text @click="privacyPolicy('login_xy')" class="main-color">注册协议</text>
  27. <text></text>
  28. <text @click="privacyPolicy('login_ys')" class="main-color">隐私政策</text>
  29. </view>
  30. </view>
  31. <view class="login-footer flex-rowc">
  32. <button @click="cancelLogin" class="btn-cancel" plain >暂不登录</button>
  33. </view>
  34. </view>
  35. <up-popup :show="show" @close="close" :round="10">
  36. <view style="padding: 10rpx 20rpx;height: 50vh;overflow-y: scroll;" v-html="content"></view>
  37. </up-popup>
  38. <!-- 客服组件 -->
  39. <CustomerService />
  40. </template>
  41. <script setup>
  42. import {
  43. getOpenIdKey,
  44. getToken,
  45. setIsLogin,
  46. setOpenIdKey,
  47. setStorage,
  48. setToken
  49. } from "../../utils/auth";
  50. import {
  51. getOpenId,
  52. getPersonalInfo,
  53. getPhoneNumber
  54. } from "../../api/system/user";
  55. import {
  56. computed,
  57. onMounted,
  58. ref
  59. } from "vue"
  60. import {
  61. useStore
  62. } from 'vuex'
  63. const store = useStore()
  64. const value = ref(false)
  65. const configList = computed(() => {
  66. return store.getters.configList
  67. })
  68. const show = ref(false)
  69. const content = ref('')
  70. const isAgree = ref(false)
  71. // 微信授权登陆
  72. const loginWx = () => {
  73. if (!isAgree.value) {
  74. return uni.showToast({
  75. title: '请先同意隐私协议',
  76. icon:'none'
  77. })
  78. }
  79. store.dispatch("login", true)
  80. }
  81. // 获取openid
  82. // if (!getOpenIdKey() && !getToken()) {
  83. // uni.login({
  84. // provider: 'weixin',
  85. // success: async (res) => {
  86. // const {
  87. // code,
  88. // data
  89. // } = await getOpenId(res.code)
  90. // if (code === 200 && data) {
  91. // let resData = JSON.parse(data)
  92. // setOpenIdKey(resData.openId)
  93. // }
  94. // },
  95. // fail: function(error) {
  96. // // 授权失败处理
  97. // uni.showToast('授权失败,请授权后再试')
  98. // }
  99. // });
  100. // }
  101. // 获取token
  102. const onGetPhoneNumber = async (e) => {
  103. // uni.login({
  104. // success: res => {
  105. // console.log("====>", res)
  106. // }
  107. // })
  108. getPhoneNumber({
  109. phoneCode: e.detail.code
  110. })
  111. // if (e.detail.errMsg === "getPhoneNumber:ok") {
  112. // if (getOpenIdKey()) {
  113. // try {
  114. // const {
  115. // data
  116. // } = await getPhoneNumber({
  117. // "openId": getOpenIdKey(),
  118. // "code": e.detail.code,
  119. // sourceType: 1
  120. // })
  121. // setToken(data.token)
  122. // setIsLogin(true)
  123. // await getUserInfo()
  124. // } catch (e) {
  125. // uni.showToast({
  126. // icon: 'error',
  127. // title: '获取手机号失败'
  128. // })
  129. // }
  130. // }
  131. // }
  132. }
  133. // // h获取用户信息
  134. // const getUserInfo = async () => {
  135. // const {
  136. // data
  137. // } = await getPersonalInfo()
  138. // setStorage('userInfo', data)
  139. // uni.navigateBack()
  140. // }
  141. const cancelLogin = () => {
  142. uni.switchTab({
  143. url: "/pages/workbenchManage/index"
  144. })
  145. }
  146. const close = () => {
  147. show.value = false
  148. }
  149. const privacyPolicy = (key) => {
  150. content.value = configList.value[key]?.paramValueArea || "";
  151. show.value = true;
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. @import "index";
  156. @import "@/style/index.scss";
  157. .agreement {
  158. color: #C7C7C7;
  159. font-size: 22rpx;
  160. line-height: 29rpx;
  161. }
  162. .login-footer {
  163. width: 100vw;
  164. position: fixed;
  165. bottom: 127rpx;
  166. .btn-cancel {
  167. color: #C7C7C7;
  168. font-size: 30rpx;
  169. line-height: 40rpx;
  170. border: none;
  171. display: inline-block;
  172. padding: 0;
  173. }
  174. }
  175. </style>