爱简收旧衣按件回收前端代码仓库
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.

379 lines
9.3 KiB

2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
  1. <template>
  2. <view class="login-container">
  3. <!-- 应用标题和副标题 -->
  4. <view class="app-header">
  5. <image :src="logoImage" alt="logo" style="width: 120rpx; height: 120rpx; display: block; margin: 0 auto;" />
  6. <view class="app-title">{{ logoName }}</view>
  7. <!-- <view class="app-subtitle">旧物很有用·回收很简单</view> -->
  8. </view>
  9. <!-- 登录操作区域 -->
  10. <view class="login-actions">
  11. <button class="login-btn" @click="handleLogin">登录</button>
  12. <button class="cancel-btn" @click="handleCancel">取消登录</button>
  13. <view class="agreement">
  14. <checkbox-group @change="handleAgreementChange" class="radio-group">
  15. <label class="radio-label">
  16. <checkbox :checked="agreed" color="#fdbd3e" class="custom-radio"/>
  17. <text class="agreement-text">我已阅读并同意</text>
  18. <text class="protocol-link" @click.stop="openProtocol('service')">服务协议</text>
  19. <text class="agreement-text"></text>
  20. <text class="protocol-link" @click.stop="openProtocol('privacy')">隐私政策</text>
  21. </label>
  22. </checkbox-group>
  23. </view>
  24. </view>
  25. <!-- <uv-divider :dashed = "true"></uv-divider> -->
  26. <!-- <view class="admin-login" @click="goToAdminLogin">管理员登录</view> -->
  27. <PrivacyPopup
  28. ref="privacyPopup"
  29. :needPhone="needPhone"
  30. @agree="handleAgreePrivacy"
  31. @reject="handleRejectPrivacy"
  32. @open-protocol="openProtocol"
  33. />
  34. <ProtocolDialog
  35. ref="protocolDialog"
  36. :show="showProtocolDialog"
  37. :title="protocolDialogTitle"
  38. :content="protocolDialogContent"
  39. @close="showProtocolDialog = false"
  40. @agree="handleProtocolAgree"
  41. @reject="handleProtocolReject"
  42. />
  43. </view>
  44. </template>
  45. <script>
  46. import PrivacyPopup from '@/wxcomponents/privacy-popup/privacy-popup.vue'
  47. import ProtocolDialog from '@/wxcomponents/protocol-dialog/protocol-dialog.vue'
  48. // import {banner} from '@/api.uts'
  49. export default {
  50. components: {
  51. PrivacyPopup,
  52. ProtocolDialog
  53. },
  54. data() {
  55. return {
  56. agreed: false,
  57. showProtocolDialog: false,
  58. protocolDialogTitle: '',
  59. protocolDialogContent: '',
  60. configData: [], // 存储 getConfig 返回的 result
  61. needPhone: false // 控制是否需要手机号授权
  62. }
  63. },
  64. computed: {
  65. logoImage() {
  66. const item = this.configData.find(i => i.keyName === 'logo_image')
  67. return item ? item.keyContent : ''
  68. },
  69. logoName() {
  70. const item = this.configData.find(i => i.keyName === 'logo_name')
  71. return item ? item.keyContent : ''
  72. }
  73. },
  74. onLoad() {
  75. this.getConfigData()
  76. },
  77. methods: {
  78. getConfigData() {
  79. this.$api('getConfig', {}, res => {
  80. // console.log('Config data response:', JSON.parse(JSON.stringify(res)) )
  81. if (res && res.success && Array.isArray(res.result)) {
  82. this.configData = res.result
  83. // console.log('Config data set:', JSON.parse(JSON.stringify(this.configData)) )
  84. }
  85. })
  86. },
  87. getConfigByKey(key) {
  88. const item = this.configData.find(i => i.keyName === key)
  89. return item ? item.keyContent : ''
  90. },
  91. handleLogin() {
  92. if (!this.agreed) {
  93. uni.showToast({
  94. title: '请阅读并勾选服务协议和隐私声明',
  95. icon: 'none'
  96. });
  97. return;
  98. }
  99. this.$refs.privacyPopup.open()
  100. // uni.showLoading({
  101. // title: '登录中...'
  102. // });
  103. // setTimeout(() => {
  104. // uni.hideLoading();
  105. // uni.showToast({
  106. // title: '登录成功'
  107. // });
  108. // uni.reLaunch({
  109. // url: '/pages/index/index'
  110. // });
  111. // }, 1500);
  112. },
  113. handleCancel() {
  114. uni.navigateBack();
  115. },
  116. handleAgreementChange(e) {
  117. // console.log(this.agreed);
  118. // this.agreed = e.detail.value.length > 0;
  119. if(this.agreed){
  120. this.agreed = false;
  121. }else{
  122. this.agreed = true;
  123. }
  124. },
  125. openProtocol(type) {
  126. console.log('Opening protocol:', type)
  127. console.log('Current configData:', this.configData)
  128. let protocol = null
  129. if (type === 'privacy') {
  130. protocol = this.configData.find(i => i.keyName === 'user_ys')
  131. } else if (type === 'service') {
  132. protocol = this.configData.find(i => i.keyName === 'user_xy')
  133. }
  134. console.log('Found protocol:', protocol)
  135. this.protocolDialogTitle = protocol ? protocol.keyValue : (type === 'privacy' ? '隐私政策' : '服务协议')
  136. this.protocolDialogContent = protocol && protocol.keyContent ? protocol.keyContent :
  137. (type === 'privacy' ?
  138. '<div style="padding: 20rpx;">暂无隐私政策内容</div>' :
  139. '<div style="padding: 20rpx;">暂无服务协议内容</div>')
  140. this.showProtocolDialog = true
  141. console.log('Dialog state:', {
  142. title: this.protocolDialogTitle,
  143. content: this.protocolDialogContent,
  144. show: this.showProtocolDialog
  145. })
  146. },
  147. goToAdminLogin() {
  148. uni.navigateTo({
  149. url: '/pages/component/admin_login'
  150. });
  151. },
  152. // 同意隐私政策
  153. handleAgreePrivacy() {
  154. uni.showLoading({
  155. title: '登录中...'
  156. })
  157. // 执行登录逻辑...
  158. let self = this
  159. wx.login({
  160. success (res) {
  161. // console.log(res.code,'code')
  162. if (res.code) {
  163. self.$api('wxLogin', {code : res.code}, res => {
  164. console.log(res,'login')
  165. if (res.code == 200) {
  166. uni.hideLoading();
  167. // console.log(res)
  168. uni.setStorageSync('token',res.result.token);
  169. uni.setStorageSync('openid',res.result.userInfo && res.result.userInfo.appletOpenid);
  170. getApp().globalData.login_status = true;
  171. if (res.result.userInfo) {
  172. const userInfo = res.result.userInfo;
  173. console.log(userInfo,'userInfo')
  174. if (!userInfo.headImage || !userInfo.nickName) {
  175. uni.navigateTo({
  176. url: '/pages/wxUserInfo'
  177. });
  178. } else {
  179. uni.reLaunch({
  180. url: '/pages/component/home'
  181. });
  182. }
  183. } else {
  184. uni.navigateTo({
  185. url: '/pages/wxUserInfo'
  186. });
  187. }
  188. }
  189. })
  190. } else {
  191. uni.hideLoading();
  192. console.log('登录失败!' + res.errMsg)
  193. }
  194. }
  195. })
  196. },
  197. // 拒绝隐私政策
  198. handleRejectPrivacy() {
  199. uni.reLaunch({ url: '/pages/component/home' });
  200. },
  201. // 打开协议页面
  202. openProtocolPage(type) {
  203. this.openProtocol(type)
  204. },
  205. handleProtocolAgree() {
  206. this.showProtocolDialog = false
  207. this.agreed = true
  208. // 你可以在这里添加同意后的其他逻辑
  209. },
  210. handleProtocolReject() {
  211. this.showProtocolDialog = false
  212. if (this.agreed) {
  213. this.agreed = false
  214. }
  215. // 你可以在这里添加拒绝后的其他逻辑
  216. }
  217. }
  218. }
  219. </script>
  220. <style scoped scss>
  221. view {
  222. padding-bottom: 0 !important;
  223. }
  224. .login-container {
  225. display: flex;
  226. flex-direction: column;
  227. height: 100vh;
  228. background-color: #f9ece5;
  229. padding: 0 40rpx;
  230. padding-bottom: env(safe-area-inset-bottom);
  231. }
  232. .app-header {
  233. margin-top: 220rpx;
  234. margin-bottom: 180rpx;
  235. text-align: center;
  236. height: 30%;
  237. }
  238. image{
  239. width: 50%;
  240. height: 50%;
  241. }
  242. .app-title {
  243. display: flex;
  244. justify-content: center;
  245. align-items: center;
  246. font-family: Alimama ShuHeiTi;
  247. font-weight: 700;
  248. font-size: 28px;
  249. line-height: 140%;
  250. letter-spacing: 0%;
  251. /* background-color: rgba(254, 208, 116, 0.8); */
  252. border-radius: 3em;
  253. letter-spacing: 0.2em;
  254. /* text-shadow: 1px 2px #f7b737; */
  255. }
  256. .app-subtitle {
  257. font-size: 28rpx;
  258. color: #fef6e3;
  259. margin-top: 1rem;
  260. letter-spacing: 0.11em;
  261. }
  262. .login-actions {
  263. /* height: 30%; */
  264. display: flex;
  265. flex-direction: column;
  266. align-items: center;
  267. justify-content: center;
  268. background-color: #f9ece5;
  269. border-radius: 30rpx;
  270. }
  271. .login-btn, .cancel-btn {
  272. width: 82%;
  273. height: 90rpx;
  274. line-height: 90rpx;
  275. border-radius: 45rpx;
  276. font-size: 32rpx;
  277. margin-bottom: 20rpx;
  278. border: none;
  279. }
  280. .login-btn {
  281. background-color: #f79400;
  282. color: white;
  283. }
  284. .cancel-btn {
  285. background-color: rgba(255, 253, 249);
  286. color: #f7990c;
  287. border: 1px solid rgba(249, 178, 71);
  288. }
  289. .agreement {
  290. /* margin-top: 40rpx; */
  291. font-size: 24rpx;
  292. color: #333;
  293. display: flex;
  294. justify-content: center;
  295. }
  296. .radio-group {
  297. display: flex;
  298. align-items: center;
  299. }
  300. /* 自定义圆形checkbox样式 */
  301. .custom-radio {
  302. /* border-radius: 50%; */
  303. width: 32rpx;
  304. height: 32rpx;
  305. transform: scale(0.7);
  306. margin-right: 8rpx;
  307. }
  308. /* 覆盖uniapp默认checkbox样式 */
  309. .custom-radio .wx-checkbox-input,
  310. .custom-radio .uni-checkbox-input {
  311. border-radius: 50% !important;
  312. width: 32rpx !important;
  313. height: 32rpx !important;
  314. }
  315. .custom-radio .wx-checkbox-input.wx-checkbox-input-checked,
  316. .custom-radio .uni-checkbox-input.uni-checkbox-input-checked {
  317. background-color: #07C160 !important;
  318. border-color: #07C160 !important;
  319. color: #ffffff !important;
  320. }
  321. /* .radio-label {
  322. display: flex;
  323. align-items: center;
  324. } */
  325. .agreement-text {
  326. margin: 0 4rpx;
  327. }
  328. .protocol-link {
  329. color: #fabe65;
  330. }
  331. .admin-login {
  332. text-align: center;
  333. color: #fffffe;
  334. font-size: 28rpx;
  335. letter-spacing: 0.15em;
  336. }
  337. </style>