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

365 lines
8.9 KiB

7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <view class="login-container">
  3. <!-- 应用标题和副标题 -->
  4. <view class="app-header">
  5. <image src="/static/home/登录.png" mode="aspectFit"></image>
  6. <view class="app-title">{{ '瀚海回收' }}</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. onLoad() {
  65. this.getConfigData()
  66. },
  67. methods: {
  68. getConfigData() {
  69. this.$api('getConfig', {}, res => {
  70. // console.log('Config data response:', JSON.parse(JSON.stringify(res)) )
  71. if (res && res.success && Array.isArray(res.result)) {
  72. this.configData = res.result
  73. console.log('Config data set:', JSON.parse(JSON.stringify(this.configData)) )
  74. }
  75. })
  76. },
  77. getConfigByKey(key) {
  78. const item = this.configData.find(i => i.keyName === key)
  79. return item ? item.keyContent : ''
  80. },
  81. handleLogin() {
  82. if (!this.agreed) {
  83. uni.showToast({
  84. title: '请阅读并勾选服务协议和隐私声明',
  85. icon: 'none'
  86. });
  87. return;
  88. }
  89. this.$refs.privacyPopup.open()
  90. // uni.showLoading({
  91. // title: '登录中...'
  92. // });
  93. // setTimeout(() => {
  94. // uni.hideLoading();
  95. // uni.showToast({
  96. // title: '登录成功'
  97. // });
  98. // uni.reLaunch({
  99. // url: '/pages/index/index'
  100. // });
  101. // }, 1500);
  102. },
  103. handleCancel() {
  104. uni.navigateBack();
  105. },
  106. handleAgreementChange(e) {
  107. // console.log(this.agreed);
  108. // this.agreed = e.detail.value.length > 0;
  109. if(this.agreed){
  110. this.agreed = false;
  111. }else{
  112. this.agreed = true;
  113. }
  114. },
  115. openProtocol(type) {
  116. console.log('Opening protocol:', type)
  117. console.log('Current configData:', this.configData)
  118. let protocol = null
  119. if (type === 'privacy') {
  120. protocol = this.configData.find(i => i.keyName === 'user_ys')
  121. } else if (type === 'service') {
  122. protocol = this.configData.find(i => i.keyName === 'user_xy')
  123. }
  124. console.log('Found protocol:', protocol)
  125. this.protocolDialogTitle = protocol ? protocol.keyValue : (type === 'privacy' ? '隐私政策' : '服务协议')
  126. this.protocolDialogContent = protocol && protocol.keyContent ? protocol.keyContent :
  127. (type === 'privacy' ?
  128. '<div style="padding: 20rpx;">暂无隐私政策内容</div>' :
  129. '<div style="padding: 20rpx;">暂无服务协议内容</div>')
  130. this.showProtocolDialog = true
  131. console.log('Dialog state:', {
  132. title: this.protocolDialogTitle,
  133. content: this.protocolDialogContent,
  134. show: this.showProtocolDialog
  135. })
  136. },
  137. goToAdminLogin() {
  138. uni.navigateTo({
  139. url: '/pages/component/admin_login'
  140. });
  141. },
  142. // 同意隐私政策
  143. handleAgreePrivacy() {
  144. uni.showLoading({
  145. title: '登录中...'
  146. })
  147. // 执行登录逻辑...
  148. let self = this
  149. wx.login({
  150. success (res) {
  151. // console.log(res.code,'code')
  152. if (res.code) {
  153. self.$api('wxLogin', {code : res.code}, res => {
  154. console.log(res,'login')
  155. if (res.code == 200) {
  156. uni.hideLoading();
  157. // console.log(res)
  158. uni.setStorageSync('token',res.result.token);
  159. uni.setStorageSync('openid',res.result.userInfo && res.result.userInfo.appletOpenid);
  160. getApp().globalData.login_status = true;
  161. if (res.result.userInfo) {
  162. // 已有userInfo,直接跳主页
  163. uni.reLaunch({
  164. url: '/pages/component/home'
  165. });
  166. } else {
  167. // 没有userInfo,弹出手机号授权
  168. self.needPhone = true;
  169. self.$refs.privacyPopup.open();
  170. }
  171. }
  172. })
  173. } else {
  174. uni.hideLoading();
  175. console.log('登录失败!' + res.errMsg)
  176. }
  177. }
  178. })
  179. },
  180. // 拒绝隐私政策
  181. handleRejectPrivacy() {
  182. uni.showToast({
  183. title: '需要同意隐私政策才能使用服务',
  184. icon: 'none'
  185. })
  186. },
  187. // 打开协议页面
  188. openProtocolPage(type) {
  189. this.openProtocol(type)
  190. },
  191. handleProtocolAgree() {
  192. this.showProtocolDialog = false
  193. this.agreed = true
  194. // 你可以在这里添加同意后的其他逻辑
  195. },
  196. handleProtocolReject() {
  197. this.showProtocolDialog = false
  198. if (this.agreed) {
  199. this.agreed = false
  200. }
  201. // 你可以在这里添加拒绝后的其他逻辑
  202. }
  203. }
  204. }
  205. </script>
  206. <style scoped scss>
  207. view {
  208. padding-bottom: 0 !important;
  209. }
  210. .login-container {
  211. display: flex;
  212. flex-direction: column;
  213. height: 100vh;
  214. background-color: #f9ece5;
  215. padding: 0 40rpx;
  216. padding-bottom: env(safe-area-inset-bottom);
  217. }
  218. .app-header {
  219. margin-top: 220rpx;
  220. margin-bottom: 180rpx;
  221. text-align: center;
  222. height: 30%;
  223. }
  224. image{
  225. width: 50%;
  226. height: 50%;
  227. }
  228. .app-title {
  229. display: flex;
  230. justify-content: center;
  231. align-items: center;
  232. font-family: Alimama ShuHeiTi;
  233. font-weight: 700;
  234. font-size: 28px;
  235. line-height: 140%;
  236. letter-spacing: 0%;
  237. /* background-color: rgba(254, 208, 116, 0.8); */
  238. border-radius: 3em;
  239. letter-spacing: 0.2em;
  240. /* text-shadow: 1px 2px #f7b737; */
  241. }
  242. .app-subtitle {
  243. font-size: 28rpx;
  244. color: #fef6e3;
  245. margin-top: 1rem;
  246. letter-spacing: 0.11em;
  247. }
  248. .login-actions {
  249. /* height: 30%; */
  250. display: flex;
  251. flex-direction: column;
  252. align-items: center;
  253. justify-content: center;
  254. background-color: #f9ece5;
  255. border-radius: 30rpx;
  256. }
  257. .login-btn, .cancel-btn {
  258. width: 82%;
  259. height: 90rpx;
  260. line-height: 90rpx;
  261. border-radius: 45rpx;
  262. font-size: 32rpx;
  263. margin-bottom: 20rpx;
  264. border: none;
  265. }
  266. .login-btn {
  267. background-color: #f79400;
  268. color: white;
  269. }
  270. .cancel-btn {
  271. background-color: rgba(255, 253, 249);
  272. color: #f7990c;
  273. border: 1px solid rgba(249, 178, 71);
  274. }
  275. .agreement {
  276. /* margin-top: 40rpx; */
  277. font-size: 24rpx;
  278. color: #333;
  279. display: flex;
  280. justify-content: center;
  281. }
  282. .radio-group {
  283. display: flex;
  284. align-items: center;
  285. }
  286. /* 自定义圆形checkbox样式 */
  287. .custom-radio {
  288. /* border-radius: 50%; */
  289. width: 32rpx;
  290. height: 32rpx;
  291. transform: scale(0.7);
  292. margin-right: 8rpx;
  293. }
  294. /* 覆盖uniapp默认checkbox样式 */
  295. .custom-radio .wx-checkbox-input,
  296. .custom-radio .uni-checkbox-input {
  297. border-radius: 50% !important;
  298. width: 32rpx !important;
  299. height: 32rpx !important;
  300. }
  301. .custom-radio .wx-checkbox-input.wx-checkbox-input-checked,
  302. .custom-radio .uni-checkbox-input.uni-checkbox-input-checked {
  303. background-color: #07C160 !important;
  304. border-color: #07C160 !important;
  305. color: #ffffff !important;
  306. }
  307. /* .radio-label {
  308. display: flex;
  309. align-items: center;
  310. } */
  311. .agreement-text {
  312. margin: 0 4rpx;
  313. }
  314. .protocol-link {
  315. color: #fabe65;
  316. }
  317. .admin-login {
  318. text-align: center;
  319. color: #fffffe;
  320. font-size: 28rpx;
  321. letter-spacing: 0.15em;
  322. }
  323. </style>