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

189 lines
3.9 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 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
4 months ago
3 months ago
3 months ago
4 months ago
3 months ago
3 months ago
4 months ago
3 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. </template>
  39. <script setup>
  40. import {
  41. getOpenIdKey,
  42. getToken,
  43. setIsLogin,
  44. setOpenIdKey,
  45. setStorage,
  46. setToken
  47. } from "../../utils/auth";
  48. import {
  49. getOpenId,
  50. getPersonalInfo,
  51. getPhoneNumber
  52. } from "../../api/system/user";
  53. import {
  54. computed,
  55. onMounted,
  56. ref
  57. } from "vue"
  58. import {
  59. useStore
  60. } from 'vuex'
  61. const store = useStore()
  62. const value = ref(false)
  63. const configList = computed(() => {
  64. return store.getters.configList
  65. })
  66. const show = ref(false)
  67. const content = ref('')
  68. const isAgree = ref(false)
  69. // 微信授权登陆
  70. const loginWx = () => {
  71. if (!isAgree.value) {
  72. return uni.showToast({
  73. title: '请先同意隐私协议',
  74. icon:'none'
  75. })
  76. }
  77. store.dispatch("login")
  78. }
  79. // 获取openid
  80. // if (!getOpenIdKey() && !getToken()) {
  81. // uni.login({
  82. // provider: 'weixin',
  83. // success: async (res) => {
  84. // const {
  85. // code,
  86. // data
  87. // } = await getOpenId(res.code)
  88. // if (code === 200 && data) {
  89. // let resData = JSON.parse(data)
  90. // setOpenIdKey(resData.openId)
  91. // }
  92. // },
  93. // fail: function(error) {
  94. // // 授权失败处理
  95. // uni.showToast('授权失败,请授权后再试')
  96. // }
  97. // });
  98. // }
  99. // 获取token
  100. const onGetPhoneNumber = async (e) => {
  101. // uni.login({
  102. // success: res => {
  103. // console.log("====>", res)
  104. // }
  105. // })
  106. getPhoneNumber({
  107. phoneCode: e.detail.code
  108. })
  109. // if (e.detail.errMsg === "getPhoneNumber:ok") {
  110. // if (getOpenIdKey()) {
  111. // try {
  112. // const {
  113. // data
  114. // } = await getPhoneNumber({
  115. // "openId": getOpenIdKey(),
  116. // "code": e.detail.code,
  117. // sourceType: 1
  118. // })
  119. // setToken(data.token)
  120. // setIsLogin(true)
  121. // await getUserInfo()
  122. // } catch (e) {
  123. // uni.showToast({
  124. // icon: 'error',
  125. // title: '获取手机号失败'
  126. // })
  127. // }
  128. // }
  129. // }
  130. }
  131. // // h获取用户信息
  132. // const getUserInfo = async () => {
  133. // const {
  134. // data
  135. // } = await getPersonalInfo()
  136. // setStorage('userInfo', data)
  137. // uni.navigateBack()
  138. // }
  139. const cancelLogin = () => {
  140. uni.switchTab({
  141. url: "/pages/workbenchManage/index"
  142. })
  143. }
  144. const close = () => {
  145. show.value = false
  146. }
  147. const privacyPolicy = (key) => {
  148. content.value = configList.value[key]?.paramValueArea || "";
  149. show.value = true;
  150. }
  151. </script>
  152. <style scoped lang="scss">
  153. @import "index";
  154. @import "@/style/index.scss";
  155. .agreement {
  156. color: #C7C7C7;
  157. font-size: 22rpx;
  158. line-height: 29rpx;
  159. }
  160. .login-footer {
  161. width: 100vw;
  162. position: fixed;
  163. bottom: 127rpx;
  164. .btn-cancel {
  165. color: #C7C7C7;
  166. font-size: 30rpx;
  167. line-height: 40rpx;
  168. border: none;
  169. display: inline-block;
  170. padding: 0;
  171. }
  172. }
  173. </style>