login.uvue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. import { ref, computed } from 'vue';
  2. const __sfc__ = defineComponent({
  3. __name: 'login',
  4. setup(__props) {
  5. const __ins = getCurrentInstance()!;
  6. const _ctx = __ins.proxy as InstanceType<typeof __sfc__>;
  7. const _cache = __ins.renderCache;
  8. const phone = ref<string>('');
  9. const code = ref<string>('');
  10. const isAgree = ref<boolean>(false);
  11. const showModal = ref<boolean>(false);
  12. const countdown = ref<number>(0);
  13. // 定义定时器变量
  14. let timer: number | null = null;
  15. const canSend = computed((): boolean => phone.value.length === 11 && countdown.value === 0);
  16. const canLogin = computed((): boolean => phone.value.length === 11 && code.value.length === 6 && isAgree.value);
  17. const codeText = computed((): string => countdown.value > 0 ? `${countdown.value}s 后重试` : '获取验证码');
  18. const goBack = (): Promise<AsyncApiSuccessResult> | null => uni.navigateBack();
  19. const oneKeyNav = (): Promise<AsyncApiSuccessResult> | null => uni.navigateTo({ url: '/pages/login/login-one-key' });
  20. const wechatLogin = () => uni.showToast({ title: '微信登录开发中', icon: 'none' });
  21. const sendCode = () => {
  22. if (!canSend.value)
  23. return;
  24. // ✅ 修复核心:先取值到局部常量,再操作
  25. const currentTimer = timer;
  26. if (currentTimer != null) {
  27. clearInterval(currentTimer);
  28. }
  29. timer = null;
  30. countdown.value = 60;
  31. uni.showToast({ title: '验证码已发送', icon: 'success' });
  32. timer = setInterval(() => {
  33. countdown.value--;
  34. if (countdown.value <= 0) {
  35. // ✅ 同样在闭包内先取局部常量
  36. const t = timer;
  37. if (t != null) {
  38. clearInterval(t);
  39. }
  40. timer = null;
  41. countdown.value = 0;
  42. }
  43. }, 1000);
  44. };
  45. const onAgreeChange = (e: any) => {
  46. // UTS 中 any 类型必须 as 成具体类型再访问属性
  47. const evt = e as UTSJSONObject;
  48. if (evt != null) {
  49. const detail = evt["detail"] as UTSJSONObject | null;
  50. if (detail != null) {
  51. const value = detail["value"] as Boolean | null;
  52. isAgree.value = (value != null) && value;
  53. return;
  54. }
  55. }
  56. isAgree.value = false;
  57. };
  58. const doLogin = () => {
  59. if (!canLogin.value) {
  60. uni.showToast({ title: isAgree.value ? '请填写完整信息' : '请先同意协议', icon: 'none' });
  61. return;
  62. }
  63. uni.showLoading({ title: '登录中...' });
  64. setTimeout(() => {
  65. uni.hideLoading();
  66. uni.showToast({ title: '登录成功', icon: 'success' });
  67. }, 1500);
  68. };
  69. const rejectAgreement = () => {
  70. showModal.value = false;
  71. uni.showToast({ title: '您拒绝了协议', icon: 'none' });
  72. };
  73. const agreeAgreement = () => {
  74. showModal.value = false;
  75. isAgree.value = true;
  76. uni.showToast({ title: '已同意协议', icon: 'success' });
  77. };
  78. return (): any | null => {
  79. const _component_uni_icons = resolveComponent("uni-icons");
  80. const _component_checkbox = resolveComponent("checkbox");
  81. return _cE("view", _uM({ class: "page-container" }), [
  82. _cE("view", _uM({
  83. class: "close-btn",
  84. onClick: goBack
  85. }), [
  86. _cV(_component_uni_icons, _uM({
  87. type: "closeempty",
  88. size: "24",
  89. color: "#333"
  90. }))
  91. ]),
  92. _cE("view", _uM({ class: "header-section" }), [
  93. _cE("text", _uM({ class: "hello-text" }), " Hello! "),
  94. _cE("text", _uM({ class: "welcome-text" }), " 欢迎来到小丁到家 "),
  95. _cE("image", _uM({
  96. src: "/static/logo-massage.png",
  97. class: "logo-img",
  98. mode: "aspectFit"
  99. }))
  100. ]),
  101. _cE("view", _uM({ class: "form-section" }), [
  102. _cE("view", _uM({ class: "input-box" }), [
  103. _cE("input", _uM({
  104. class: "input-field",
  105. type: "number",
  106. placeholder: "请输入手机号码",
  107. modelValue: phone.value,
  108. onInput: ($event: UniInputEvent) => { (phone).value = $event.detail.value; },
  109. maxlength: "11"
  110. }), null, 40 /* PROPS, NEED_HYDRATION */, ["modelValue", "onInput"])
  111. ]),
  112. _cE("view", _uM({ class: "input-box row-between" }), [
  113. _cE("input", _uM({
  114. class: "input-field",
  115. type: "number",
  116. placeholder: "请输入验证码",
  117. modelValue: code.value,
  118. onInput: ($event: UniInputEvent) => { (code).value = $event.detail.value; },
  119. maxlength: "6"
  120. }), null, 40 /* PROPS, NEED_HYDRATION */, ["modelValue", "onInput"]),
  121. _cE("text", _uM({
  122. class: _nC(["code-btn", _uM({ disabled: !canSend.value })]),
  123. onClick: sendCode
  124. }), _tD(codeText.value), 3 /* TEXT, CLASS */)
  125. ]),
  126. _cE("view", _uM({
  127. class: _nC(["login-btn", _uM({ disabled: !canLogin.value })]),
  128. onClick: doLogin
  129. }), " 登录 ", 2 /* CLASS */),
  130. _cE("view", _uM({ class: "agree-row row-start" }), [
  131. _cV(_component_checkbox, _uM({
  132. checked: isAgree.value,
  133. onChange: onAgreeChange,
  134. style: _nS(_uM({ "transform": "scale(0.8)" }))
  135. }), null, 8 /* PROPS */, ["checked", "style"]),
  136. _cE("view", _uM({ class: "agree-content" }), [
  137. _cE("text", _uM({ class: "agree-text" }), [
  138. " 我已阅读并同意 ",
  139. _cE("text", _uM({ class: "link-text" }), " 《用户协议》 "),
  140. _cE("text", _uM({ class: "link-text" }), " 《隐私政策》 "),
  141. _cE("text", _uM({ class: "link-text" }), " 《上门按摩服务行业平台公约》 "),
  142. " ,未注册的手机号将自动创建小丁到家账号 "
  143. ])
  144. ])
  145. ])
  146. ]),
  147. _cE("view", _uM({ class: "footer-section" }), [
  148. _cE("view", _uM({ class: "divider-row row-center" }), [
  149. _cE("view", _uM({ class: "line" })),
  150. _cE("text", _uM({ class: "divider-text" }), " 其他登录方式 "),
  151. _cE("view", _uM({ class: "line" }))
  152. ]),
  153. _cE("view", _uM({ class: "methods-row row-center" }), [
  154. _cE("view", _uM({
  155. class: "method-item column-center",
  156. onClick: oneKeyNav
  157. }), [
  158. _cE("view", _uM({ class: "icon-box blue-bg" }), [
  159. _cV(_component_uni_icons, _uM({
  160. type: "checkmark",
  161. size: "20",
  162. color: "#fff"
  163. }))
  164. ]),
  165. _cE("text", _uM({ class: "method-name" }), " 一键登录 ")
  166. ]),
  167. _cE("view", _uM({
  168. class: "method-item column-center",
  169. onClick: wechatLogin
  170. }), [
  171. _cE("view", _uM({ class: "icon-box green-bg" }), [
  172. _cV(_component_uni_icons, _uM({
  173. type: "weixin",
  174. size: "20",
  175. color: "#fff"
  176. }))
  177. ]),
  178. _cE("text", _uM({ class: "method-name" }), " 微信登录 ")
  179. ])
  180. ])
  181. ]),
  182. isTrue(showModal.value)
  183. ? _cE("view", _uM({
  184. key: 0,
  185. class: "modal-mask",
  186. onClick: () => { showModal.value = false; }
  187. }), [
  188. _cE("view", _uM({
  189. class: "modal-box",
  190. onClick: withModifiers(() => { }, ["stop"])
  191. }), [
  192. _cE("text", _uM({ class: "modal-title" }), " 服务协议及隐私政策 "),
  193. _cE("scroll-view", _uM({
  194. "scroll-y": "",
  195. class: "modal-scroll"
  196. }), [
  197. _cE("text", _uM({ class: "modal-welcome" }), " 欢迎您使用小丁到家! "),
  198. _cE("text", _uM({ class: "modal-desc" }), [
  199. " 请你务必审慎阅读、并充分理解 ",
  200. _cE("text", _uM({ class: "modal-link" }), " 《用户协议》 "),
  201. " 和 ",
  202. _cE("text", _uM({ class: "modal-link" }), " 《隐私政策》 "),
  203. " ,协议内容包括但不限于: "
  204. ]),
  205. _cE("text", _uM({ class: "modal-list" }), " 1、在您使用软件及服务的过程中,向您提供相关基本功能,我们将根据合法、正当、必要的原则,收集或使用必要的个人信息; "),
  206. _cE("text", _uM({ class: "modal-list" }), " 2、基于您的授权,我们可能会获取您的地理位置、相册、相机等相关软件权限; "),
  207. _cE("text", _uM({ class: "modal-list" }), " 3、我们会采取符合标准的技术措施和数据安全措施来保护您的个人信息安全; "),
  208. _cE("text", _uM({ class: "modal-list" }), " 4、您可以查询,更正,管理您的个人信息,我们也提供账户注销的渠道; "),
  209. _cE("text", _uM({ class: "modal-footer" }), " 如您同意以上协议内容,请点击“同意”开始使用我们的产品和服务,我们依法尽全力保护您的个人信息。 ")
  210. ]),
  211. _cE("view", _uM({ class: "modal-btns row-between" }), [
  212. _cE("text", _uM({
  213. class: "modal-btn reject",
  214. onClick: rejectAgreement
  215. }), " 拒绝并退出 "),
  216. _cE("text", _uM({
  217. class: "modal-btn agree",
  218. onClick: agreeAgreement
  219. }), " 同意 ")
  220. ])
  221. ], 8 /* PROPS */, ["onClick"])
  222. ], 8 /* PROPS */, ["onClick"])
  223. : _cC("v-if", true)
  224. ]);
  225. };
  226. }
  227. });
  228. export default __sfc__;
  229. const GenPagesLoginLoginStyles = [_uM([["page-container", _pS(_uM([["backgroundImage", "linear-gradient(180deg, #e0f7fa 0%, #fff8e1 100%)"], ["backgroundColor", "rgba(0,0,0,0)"], ["height", "100%"], ["paddingTop", "40rpx"], ["paddingRight", "30rpx"], ["paddingBottom", "40rpx"], ["paddingLeft", "30rpx"], ["boxSizing", "border-box"]]))], ["close-btn", _pS(_uM([["position", "absolute"], ["top", "40rpx"], ["right", "30rpx"], ["zIndex", 10]]))], ["header-section", _pS(_uM([["alignItems", "center"], ["marginBottom", "60rpx"]]))], ["hello-text", _pS(_uM([["fontSize", "48rpx"], ["fontWeight", "bold"], ["color", "#333333"], ["marginBottom", "10rpx"]]))], ["welcome-text", _pS(_uM([["fontSize", "32rpx"], ["color", "#666666"], ["marginBottom", "30rpx"]]))], ["logo-img", _pS(_uM([["width", "300rpx"], ["height", "300rpx"], ["borderTopLeftRadius", "150rpx"], ["borderTopRightRadius", "150rpx"], ["borderBottomRightRadius", "150rpx"], ["borderBottomLeftRadius", "150rpx"], ["backgroundColor", "rgba(255,255,255,0.3)"]]))], ["form-section", _pS(_uM([["marginBottom", "60rpx"]]))], ["input-box", _pS(_uM([["backgroundColor", "#ffffff"], ["borderTopLeftRadius", "30rpx"], ["borderTopRightRadius", "30rpx"], ["borderBottomRightRadius", "30rpx"], ["borderBottomLeftRadius", "30rpx"], ["paddingTop", "20rpx"], ["paddingRight", "30rpx"], ["paddingBottom", "20rpx"], ["paddingLeft", "30rpx"], ["marginBottom", "30rpx"], ["boxShadow", "0 2rpx 8rpx rgba(0, 0, 0, 0.05)"]]))], ["input-field", _pS(_uM([["flexGrow", 1], ["flexShrink", 1], ["flexBasis", "0%"], ["fontSize", "28rpx"], ["color", "#333333"]]))], ["code-btn", _uM([["", _uM([["fontSize", "26rpx"], ["color", "#ffc107"], ["fontWeight", "bold"], ["whiteSpace", "nowrap"]])], [".disabled", _uM([["color", "#cccccc"]])]])], ["login-btn", _uM([["", _uM([["backgroundImage", "linear-gradient(90deg, #ffc107, #ffca2c)"], ["backgroundColor", "rgba(0,0,0,0)"], ["color", "#ffffff"], ["fontSize", "32rpx"], ["fontWeight", "bold"], ["textAlign", "center"], ["paddingTop", "24rpx"], ["paddingRight", 0], ["paddingBottom", "24rpx"], ["paddingLeft", 0], ["borderTopLeftRadius", "30rpx"], ["borderTopRightRadius", "30rpx"], ["borderBottomRightRadius", "30rpx"], ["borderBottomLeftRadius", "30rpx"], ["marginBottom", "30rpx"], ["boxShadow", "0 4rpx 12rpx rgba(255, 193, 7, 0.3)"]])], [".disabled", _uM([["backgroundImage", "none"], ["backgroundColor", "#dddddd"], ["color", "#999999"], ["boxShadow", "none"]])]])], ["agree-row", _pS(_uM([["alignItems", "flex-start"]]))], ["agree-content", _pS(_uM([["flexGrow", 1], ["flexShrink", 1], ["flexBasis", "0%"], ["marginLeft", "10rpx"]]))], ["agree-text", _pS(_uM([["fontSize", "24rpx"], ["color", "#999999"], ["lineHeight", 1.6]]))], ["link-text", _pS(_uM([["color", "#00b894"], ["borderBottomWidth", "1rpx"], ["borderBottomStyle", "solid"], ["borderBottomColor", "#00b894"]]))], ["footer-section", _pS(_uM([["marginTop", "auto"]]))], ["divider-row", _pS(_uM([["marginBottom", "40rpx"], ["alignItems", "center"]]))], ["line", _pS(_uM([["flexGrow", 1], ["flexShrink", 1], ["flexBasis", "0%"], ["height", "1rpx"], ["backgroundColor", "#dddddd"]]))], ["divider-text", _pS(_uM([["fontSize", "26rpx"], ["color", "#999999"], ["marginTop", 0], ["marginRight", "20rpx"], ["marginBottom", 0], ["marginLeft", "20rpx"]]))], ["methods-row", _pS(_uM([["justifyContent", "center"], ["marginBottom", "40rpx"]]))], ["method-item", _pS(_uM([["marginRight", "60rpx"], ["alignItems", "center"], ["marginRight:last-child", 0]]))], ["icon-box", _pS(_uM([["width", "80rpx"], ["height", "80rpx"], ["borderTopLeftRadius", "40rpx"], ["borderTopRightRadius", "40rpx"], ["borderBottomRightRadius", "40rpx"], ["borderBottomLeftRadius", "40rpx"], ["justifyContent", "center"], ["alignItems", "center"], ["marginBottom", "15rpx"]]))], ["blue-bg", _pS(_uM([["backgroundImage", "linear-gradient(135deg, #4a90e2, #67b26f)"], ["backgroundColor", "rgba(0,0,0,0)"]]))], ["green-bg", _pS(_uM([["backgroundImage", "linear-gradient(135deg, #00b894, #00cec9)"], ["backgroundColor", "rgba(0,0,0,0)"]]))], ["method-name", _pS(_uM([["fontSize", "26rpx"], ["color", "#666666"]]))], ["modal-mask", _pS(_uM([["position", "fixed"], ["top", 0], ["left", 0], ["right", 0], ["bottom", 0], ["backgroundColor", "rgba(0,0,0,0.5)"], ["justifyContent", "center"], ["alignItems", "center"], ["zIndex", 100]]))], ["modal-box", _pS(_uM([["backgroundColor", "#ffffff"], ["borderTopLeftRadius", "20rpx"], ["borderTopRightRadius", "20rpx"], ["borderBottomRightRadius", "20rpx"], ["borderBottomLeftRadius", "20rpx"], ["paddingTop", "40rpx"], ["paddingRight", "30rpx"], ["paddingBottom", "40rpx"], ["paddingLeft", "30rpx"], ["width", "600rpx"], ["maxHeight", "800rpx"], ["flexDirection", "column"]]))], ["modal-title", _pS(_uM([["fontSize", "36rpx"], ["fontWeight", "bold"], ["color", "#333333"], ["textAlign", "center"], ["marginBottom", "20rpx"]]))], ["modal-scroll", _pS(_uM([["flexGrow", 1], ["flexShrink", 1], ["flexBasis", "0%"], ["marginBottom", "20rpx"]]))], ["modal-welcome", _pS(_uM([["fontSize", "28rpx"], ["color", "#333333"], ["marginBottom", "15rpx"]]))], ["modal-desc", _pS(_uM([["fontSize", "26rpx"], ["color", "#666666"], ["lineHeight", 1.6], ["marginBottom", "15rpx"]]))], ["modal-link", _pS(_uM([["color", "#00b894"], ["borderBottomWidth", "1rpx"], ["borderBottomStyle", "solid"], ["borderBottomColor", "#00b894"]]))], ["modal-list", _pS(_uM([["fontSize", "26rpx"], ["color", "#666666"], ["lineHeight", 1.6], ["marginBottom", "10rpx"]]))], ["modal-footer", _pS(_uM([["fontSize", "26rpx"], ["color", "#666666"], ["lineHeight", 1.6], ["marginBottom", "10rpx"]]))], ["modal-btns", _pS(_uM([["borderTopWidth", "1rpx"], ["borderTopStyle", "solid"], ["borderTopColor", "#eeeeee"], ["paddingTop", "20rpx"]]))], ["modal-btn", _uM([["", _uM([["flexGrow", 1], ["flexShrink", 1], ["flexBasis", "0%"], ["textAlign", "center"], ["fontSize", "28rpx"], ["fontWeight", "bold"], ["paddingTop", "15rpx"], ["paddingRight", 0], ["paddingBottom", "15rpx"], ["paddingLeft", 0]])], [".reject", _uM([["color", "#999999"], ["marginRight", "20rpx"]])], [".agree", _uM([["color", "#00b894"]])]])], ["row-between", _pS(_uM([["flexDirection", "row"], ["justifyContent", "space-between"], ["alignItems", "center"]]))], ["row-start", _pS(_uM([["flexDirection", "row"], ["alignItems", "flex-start"]]))], ["row-center", _pS(_uM([["flexDirection", "row"], ["justifyContent", "center"], ["alignItems", "center"]]))], ["column-center", _pS(_uM([["flexDirection", "column"], ["justifyContent", "center"], ["alignItems", "center"]]))]])];
  230. //# sourceMappingURL=login.uvue.map