index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view class="login-register" v-if="userStore.showLoginModal">
  3. <view class="lr-box" v-if="!userStore.isRegister">
  4. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/c79318ee-e219-4f01-9dfb-91d7180a0972.png" class="lr-box-topbg" mode="widthFix"></image>
  5. <view class="lr-box-top adfacjb">
  6. <image class="lr-box-top-left" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/64d76db1-be28-4ba2-a8f0-57e2408beebc.png"></image>
  7. <image class="lr-box-top-right" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/c3c4fa76-32d2-4d11-915d-5e655c6b5c72.png" @click="close"></image>
  8. </view>
  9. <view class="lr-box-title">
  10. <p class="p">欢迎来到善行少年</p>
  11. <p class="p tip">首次登录需要简单填写信息即可进入</p>
  12. </view>
  13. <view class="lr-box-form">
  14. <view class="lr-box-form-item adfacjb">
  15. <view class="lr-box-form-item-left adfac">
  16. <view class="text" style="margin-right: 32rpx;"><span style="color: #F4657A;">*</span>手机号码</view>
  17. <up-input v-model="register.phone" border="none" placeholder="请输入手机号码"></up-input>
  18. </view>
  19. <view class="lr-box-form-item-right">
  20. <button class="yjsq" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber" privacy-desc="用于获取您的手机号码,方便您快速注册。">一键授权</button>
  21. </view>
  22. </view>
  23. <view class="lr-box-form-item adfacjb">
  24. <view class="lr-box-form-item-left adfac">
  25. <view class="text"><span style="color: #F4657A;">*</span>头像</view>
  26. <!-- <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/a2944f51-2c7b-41e7-8206-8a3be1f76d11.png" v-if="!register.avatarPath"></image>
  27. <image :src="register.avatarPath"></image> -->
  28. <up-upload
  29. :fileList="fileList"
  30. @afterRead="afterRead"
  31. @delete="deletePic"
  32. :maxCount="1"
  33. width="120rpx"
  34. height="120rpx"
  35. >
  36. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/a2944f51-2c7b-41e7-8206-8a3be1f76d11.png"
  37. mode="widthFix" style="width: 120rpx;height: 120rpx;"></image>
  38. </up-upload>
  39. </view>
  40. <view class="lr-box-form-item-right">
  41. <button class="yjsq" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">设置</button>
  42. </view>
  43. </view>
  44. <view class="lr-box-form-item adfacjb">
  45. <view class="lr-box-form-item-left">
  46. <view class="text"><span style="color: #F4657A;">*</span>用户名</view>
  47. </view>
  48. <view class="lr-box-form-item-right">
  49. <up-input v-model="register.nickName" border="none" inputAlign="right" placeholder="请输入真实姓名"></up-input>
  50. </view>
  51. </view>
  52. <view class="lr-box-form-item adfacjb">
  53. <view class="lr-box-form-item-left">
  54. <view class="text">家庭公益名称</view>
  55. </view>
  56. <view class="lr-box-form-item-right">
  57. <up-input v-model="register.welfareName" border="none" inputAlign="right" placeholder="请输入至少三个字"></up-input>
  58. </view>
  59. </view>
  60. <view class="lr-box-form-item adfacjb">
  61. <view class="lr-box-form-item-left">
  62. <view class="text">家庭公益口号</view>
  63. </view>
  64. <view class="lr-box-form-item-right">
  65. <up-input v-model="register.welfareSlogan" border="none" inputAlign="right" placeholder="家庭公益口号"></up-input>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="lr-box-btns">
  70. <view class="btn" @click="toRegister">立即注册</view>
  71. <view class="btn login" @click="readLogin">已有账号,去登录</view>
  72. </view>
  73. </view>
  74. <view class="lr-box login" v-else>
  75. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/c79318ee-e219-4f01-9dfb-91d7180a0972.png" class="lr-box-topbg" mode="widthFix"></image>
  76. <view class="lr-box-top login adfacjb">
  77. <image class="lr-box-top-left login" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/d0f892c8-1f96-4c86-b62b-a8b027b4bf6e.png"></image>
  78. <image class="lr-box-top-right" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/c3c4fa76-32d2-4d11-915d-5e655c6b5c72.png" @click="close"></image>
  79. </view>
  80. <view class="lr-box-memo">公益献爱心 真情暖人心!</view>
  81. <view class="lr-box-agree adfac">
  82. <image v-if="agree" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/87b5b244-d14f-43cd-991b-4ac9f48d909e.png" @click="changeAgree"></image>
  83. <image v-else src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/b8a5cabd-57f8-4ad7-9677-f6372423c50a.png" @click="changeAgree"></image>
  84. <view class="text">我已阅读并同意<span>《善行少年小程序隐私政策》</span>及<span>《善行少年服务协议》</span></view>
  85. </view>
  86. <view class="lr-box-login">
  87. <button class="phone-login" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumberLogin" privacy-desc="用于获取您的手机号码,方便您进行登录。">手机号登录</button>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. <script setup name="">
  93. import { ref, getCurrentInstance } from 'vue'
  94. const { proxy } = getCurrentInstance()
  95. import { useUserStore } from '@/common/stores/user.js';
  96. const userStore = useUserStore();
  97. const register = ref({
  98. phone:null,
  99. avatarPath:null,
  100. nickName:null,
  101. welfareName:null,
  102. welfareSlogan:null,
  103. })
  104. const agree = ref(false)
  105. const fileList = ref([])
  106. const close = () => {
  107. userStore.closeLoginModal();
  108. }
  109. const decryptPhoneNumber = e => {
  110. if(e.detail.code) getPhone(e.detail.code);
  111. }
  112. const onChooseAvatar = e => {
  113. register.value.avatarPath = e.detail.avatarUrl;
  114. }
  115. const getPhone = code => {
  116. proxy.$api.get(`/wx/getPhone/${code}`).then(({data:res})=>{
  117. if(res.code !== 0) return proxy.$showToast(res.msg)
  118. register.value.phone = res.data;
  119. })
  120. }
  121. const toRegister = () => {
  122. if(!proxy.$reg.mobile(register.value.phone)) return proxy.$showToast('请输入正确的手机号码')
  123. if(!register.value.avatarPath) return proxy.$showToast('请设置头像')
  124. if(!register.value.nickName) return proxy.$showToast('请输入真实姓名')
  125. userStore.register(register.value);
  126. }
  127. const readLogin = () => {
  128. userStore.isRegister = true;
  129. }
  130. const changeAgree = () => {
  131. agree.value = !agree.value;
  132. }
  133. const afterRead = e => {
  134. }
  135. const deletePic = event => {
  136. fileList.value.splice(event.index, 1);
  137. register.value.avatarPath = '';
  138. }
  139. const decryptPhoneNumberLogin = e => {
  140. if(e.detail.code) toPhoneLogin(e.detail.code);
  141. }
  142. const toPhoneLogin = code => {
  143. if(!agree.value) return proxy.$showToast('请勾选隐私政策和服务协议')
  144. wx.login({
  145. success(res){
  146. userStore.login({code:res.code,phoneCode:code});
  147. }
  148. })
  149. }
  150. </script>
  151. <style scoped lang="scss">
  152. .login-register{
  153. position: fixed;
  154. top: 0;
  155. left: 0;
  156. right: 0;
  157. bottom: 0;
  158. background: rgba(0, 0, 0, .4);
  159. z-index: 9999;
  160. display: flex;
  161. flex-direction: column;
  162. justify-content: flex-end;
  163. .lr-box{
  164. background: #F7F7F7;
  165. border-radius: 24rpx 24rpx 0rpx 0rpx;
  166. padding: 58rpx 30rpx 68rpx;
  167. position: relative;
  168. &.login{
  169. padding: 32rpx 40rpx 88rpx;
  170. }
  171. &-topbg{
  172. width: 100%;
  173. position: absolute;
  174. left: 0;
  175. top: 0;
  176. }
  177. &-top{
  178. position: relative;
  179. padding: 0 10rpx 0 34rpx;
  180. &.login{
  181. padding: 0;
  182. }
  183. &-left{
  184. width: 158rpx;
  185. height: 88rpx;
  186. &.login{
  187. width: 224rpx;
  188. height: 48rpx;
  189. }
  190. }
  191. &-right{
  192. width: 28rpx;
  193. height: 28rpx;
  194. }
  195. }
  196. &-title{
  197. position: relative;
  198. margin-top: 18rpx;
  199. padding-left: 34rpx;
  200. .p{
  201. font-family: PingFangSC, PingFang SC;
  202. font-weight: 600;
  203. font-size: 44rpx;
  204. color: #151B29;
  205. line-height: 62rpx;
  206. &.tip{
  207. font-weight: 400;
  208. font-size: 26rpx;
  209. color: rgba(21,27,41,0.61);
  210. line-height: 37rpx;
  211. margin-top: 10rpx;
  212. }
  213. }
  214. }
  215. &-form{
  216. position: relative;
  217. margin-top: 10rpx;
  218. &-item{
  219. height: 120rpx;
  220. background: #FFFFFF;
  221. border-radius: 16rpx;
  222. border: 1rpx solid #E0E1E4;
  223. padding: 0 30rpx;
  224. margin-top: 20rpx;
  225. &-left{
  226. width: 370rpx;
  227. .text{
  228. font-family: PingFangSC, PingFang SC;
  229. font-weight: 400;
  230. font-size: 30rpx;
  231. color: #151B29;
  232. line-height: 42rpx;
  233. }
  234. image{
  235. width: 60rpx;
  236. height: 60rpx;
  237. border-radius: 50%;
  238. margin-left: 28rpx;
  239. }
  240. }
  241. &-right{
  242. width: calc(100% - 370rpx);
  243. padding-left: 20rpx;
  244. box-sizing: border-box;
  245. .yjsq{
  246. font-family: PingFangSC, PingFang SC;
  247. font-weight: 400;
  248. font-size: 28rpx;
  249. color: #0593FE;
  250. line-height: 40rpx;
  251. background-color: transparent;
  252. text-align: right;
  253. padding: 0;
  254. &::after{
  255. width: auto;
  256. border: none;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. &-btns{
  263. margin-top: 20rpx;
  264. padding: 0 10rpx;
  265. overflow: hidden;
  266. .btn{
  267. width: 100%;
  268. height: 90rpx;
  269. background: #B7F358;
  270. border-radius: 45rpx;
  271. font-family: PingFang-SC, PingFang-SC;
  272. font-weight: bold;
  273. font-size: 32rpx;
  274. color: #151B29;
  275. line-height: 90rpx;
  276. text-align: center;
  277. letter-spacing: 2rpx;
  278. margin-top: 20rpx;
  279. &.login{
  280. background: #ECEEF5;
  281. }
  282. }
  283. }
  284. &-memo{
  285. position: relative;
  286. font-family: PingFangSC, PingFang SC;
  287. font-weight: 400;
  288. font-size: 26rpx;
  289. color: #151B29;
  290. line-height: 36rpx;
  291. letter-spacing: 4rpx;
  292. margin-top: 41rpx;
  293. }
  294. &-agree{
  295. position: relative;
  296. margin-top: 95rpx;
  297. image{
  298. width: 48rpx;
  299. height: 48rpx;
  300. }
  301. .text{
  302. width: calc(100% - 48rpx);
  303. padding-left: 19rpx;
  304. box-sizing: border-box;
  305. font-family: PingFangSC, PingFang SC;
  306. font-weight: 400;
  307. font-size: 26rpx;
  308. color: #151B29;
  309. line-height: 36rpx;
  310. label{
  311. color: #E77687;
  312. }
  313. }
  314. }
  315. &-login{
  316. margin-top: 122rpx;
  317. .phone-login{
  318. width: 100%;
  319. height: 90rpx;
  320. background: #B7F358;
  321. border-radius: 45rpx;
  322. font-family: PingFang-SC, PingFang-SC;
  323. font-weight: bold;
  324. font-size: 32rpx;
  325. color: #151B29;
  326. line-height: 90rpx;
  327. text-align: center;
  328. letter-spacing: 2rpx;
  329. &::after{
  330. border: none;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. </style>