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

378 lines
9.2 KiB

3 weeks ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
3 weeks ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
3 weeks ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
3 weeks ago
1 week ago
3 weeks ago
1 week ago
1 week ago
1 week ago
3 weeks ago
1 week ago
3 weeks ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week 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. if (!userInfo.avatarUrl || !userInfo.nickName) {
  174. uni.navigateTo({
  175. url: '/pages/wxUserInfo'
  176. });
  177. } else {
  178. uni.reLaunch({
  179. url: '/pages/component/home'
  180. });
  181. }
  182. } else {
  183. uni.navigateTo({
  184. url: '/pages/wxUserInfo'
  185. });
  186. }
  187. }
  188. })
  189. } else {
  190. uni.hideLoading();
  191. console.log('登录失败!' + res.errMsg)
  192. }
  193. }
  194. })
  195. },
  196. // 拒绝隐私政策
  197. handleRejectPrivacy() {
  198. uni.reLaunch({ url: '/pages/component/home' });
  199. },
  200. // 打开协议页面
  201. openProtocolPage(type) {
  202. this.openProtocol(type)
  203. },
  204. handleProtocolAgree() {
  205. this.showProtocolDialog = false
  206. this.agreed = true
  207. // 你可以在这里添加同意后的其他逻辑
  208. },
  209. handleProtocolReject() {
  210. this.showProtocolDialog = false
  211. if (this.agreed) {
  212. this.agreed = false
  213. }
  214. // 你可以在这里添加拒绝后的其他逻辑
  215. }
  216. }
  217. }
  218. </script>
  219. <style scoped scss>
  220. view {
  221. padding-bottom: 0 !important;
  222. }
  223. .login-container {
  224. display: flex;
  225. flex-direction: column;
  226. height: 100vh;
  227. background-color: #f9ece5;
  228. padding: 0 40rpx;
  229. padding-bottom: env(safe-area-inset-bottom);
  230. }
  231. .app-header {
  232. margin-top: 220rpx;
  233. margin-bottom: 180rpx;
  234. text-align: center;
  235. height: 30%;
  236. }
  237. image{
  238. width: 50%;
  239. height: 50%;
  240. }
  241. .app-title {
  242. display: flex;
  243. justify-content: center;
  244. align-items: center;
  245. font-family: Alimama ShuHeiTi;
  246. font-weight: 700;
  247. font-size: 28px;
  248. line-height: 140%;
  249. letter-spacing: 0%;
  250. /* background-color: rgba(254, 208, 116, 0.8); */
  251. border-radius: 3em;
  252. letter-spacing: 0.2em;
  253. /* text-shadow: 1px 2px #f7b737; */
  254. }
  255. .app-subtitle {
  256. font-size: 28rpx;
  257. color: #fef6e3;
  258. margin-top: 1rem;
  259. letter-spacing: 0.11em;
  260. }
  261. .login-actions {
  262. /* height: 30%; */
  263. display: flex;
  264. flex-direction: column;
  265. align-items: center;
  266. justify-content: center;
  267. background-color: #f9ece5;
  268. border-radius: 30rpx;
  269. }
  270. .login-btn, .cancel-btn {
  271. width: 82%;
  272. height: 90rpx;
  273. line-height: 90rpx;
  274. border-radius: 45rpx;
  275. font-size: 32rpx;
  276. margin-bottom: 20rpx;
  277. border: none;
  278. }
  279. .login-btn {
  280. background-color: #f79400;
  281. color: white;
  282. }
  283. .cancel-btn {
  284. background-color: rgba(255, 253, 249);
  285. color: #f7990c;
  286. border: 1px solid rgba(249, 178, 71);
  287. }
  288. .agreement {
  289. /* margin-top: 40rpx; */
  290. font-size: 24rpx;
  291. color: #333;
  292. display: flex;
  293. justify-content: center;
  294. }
  295. .radio-group {
  296. display: flex;
  297. align-items: center;
  298. }
  299. /* 自定义圆形checkbox样式 */
  300. .custom-radio {
  301. /* border-radius: 50%; */
  302. width: 32rpx;
  303. height: 32rpx;
  304. transform: scale(0.7);
  305. margin-right: 8rpx;
  306. }
  307. /* 覆盖uniapp默认checkbox样式 */
  308. .custom-radio .wx-checkbox-input,
  309. .custom-radio .uni-checkbox-input {
  310. border-radius: 50% !important;
  311. width: 32rpx !important;
  312. height: 32rpx !important;
  313. }
  314. .custom-radio .wx-checkbox-input.wx-checkbox-input-checked,
  315. .custom-radio .uni-checkbox-input.uni-checkbox-input-checked {
  316. background-color: #07C160 !important;
  317. border-color: #07C160 !important;
  318. color: #ffffff !important;
  319. }
  320. /* .radio-label {
  321. display: flex;
  322. align-items: center;
  323. } */
  324. .agreement-text {
  325. margin: 0 4rpx;
  326. }
  327. .protocol-link {
  328. color: #fabe65;
  329. }
  330. .admin-login {
  331. text-align: center;
  332. color: #fffffe;
  333. font-size: 28rpx;
  334. letter-spacing: 0.15em;
  335. }
  336. </style>