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

155 lines
3.1 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
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 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. </view>
  6. <view class="login-submit">
  7. <up-button type="primary" text="授权手机号登录" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber"
  8. shape="circle" color="#FFBF60"></up-button>
  9. <up-button class="mt24" type="primary" text="微信授权登陆" @tap="loginWx" shape="circle"
  10. color="#FFBF60"></up-button>
  11. </view>
  12. <view class="flex-rowc">
  13. <view class="select">
  14. <image mode="widthFix"></image>
  15. </view>
  16. <view class="size-26">
  17. <text>我已阅读并同意猫爸狗妈</text>
  18. <text class="main-color">注册协议</text>
  19. <text></text>
  20. <text class="main-color">隐私政策</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="footer size-30 flex-rowc w100">
  25. 暂不登陆
  26. </view>
  27. </template>
  28. <script setup>
  29. import {
  30. getOpenIdKey,
  31. getToken,
  32. setIsLogin,
  33. setOpenIdKey,
  34. setStorage,
  35. setToken
  36. } from "../../utils/auth";
  37. import {
  38. getOpenId,
  39. getPersonalInfo,
  40. getPhoneNumber
  41. } from "../../api/system/user";
  42. import {
  43. computed,
  44. onMounted,
  45. ref
  46. } from "vue"
  47. import {
  48. useStore
  49. } from 'vuex'
  50. const store = useStore()
  51. const value = ref(false)
  52. const configList = computed(() => {
  53. return store.getters.configList
  54. })
  55. onMounted(() => {
  56. console.log("configList",configList)
  57. })
  58. // 微信授权登陆
  59. const loginWx = () => {
  60. store.dispatch("login")
  61. }
  62. // 获取openid
  63. // if (!getOpenIdKey() && !getToken()) {
  64. // uni.login({
  65. // provider: 'weixin',
  66. // success: async (res) => {
  67. // const {
  68. // code,
  69. // data
  70. // } = await getOpenId(res.code)
  71. // if (code === 200 && data) {
  72. // let resData = JSON.parse(data)
  73. // setOpenIdKey(resData.openId)
  74. // }
  75. // },
  76. // fail: function(error) {
  77. // // 授权失败处理
  78. // uni.showToast('授权失败,请授权后再试')
  79. // }
  80. // });
  81. // }
  82. // 获取token
  83. const onGetPhoneNumber = async (e) => {
  84. // uni.login({
  85. // success: res => {
  86. // console.log("====>", res)
  87. // }
  88. // })
  89. getPhoneNumber({
  90. phoneCode: e.detail.code
  91. })
  92. // if (e.detail.errMsg === "getPhoneNumber:ok") {
  93. // if (getOpenIdKey()) {
  94. // try {
  95. // const {
  96. // data
  97. // } = await getPhoneNumber({
  98. // "openId": getOpenIdKey(),
  99. // "code": e.detail.code,
  100. // sourceType: 1
  101. // })
  102. // setToken(data.token)
  103. // setIsLogin(true)
  104. // await getUserInfo()
  105. // } catch (e) {
  106. // uni.showToast({
  107. // icon: 'error',
  108. // title: '获取手机号失败'
  109. // })
  110. // }
  111. // }
  112. // }
  113. }
  114. // // h获取用户信息
  115. // const getUserInfo = async () => {
  116. // const {
  117. // data
  118. // } = await getPersonalInfo()
  119. // setStorage('userInfo', data)
  120. // uni.navigateBack()
  121. // }
  122. </script>
  123. <style scoped lang="scss">
  124. @import "index";
  125. @import "@/style/index.scss";
  126. .select {
  127. width: 24rpx;
  128. height: 24rpx;
  129. border-radius: 50%;
  130. border: 1rpx solid #C7C7C7;
  131. margin-right: 8rpx;
  132. .active {
  133. background-color: $mainColor;
  134. }
  135. }
  136. .footer {
  137. color: #C7C7C7;
  138. position: fixed;
  139. bottom: 100rpx;
  140. }
  141. </style>