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

188 lines
6.9 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const PrivacyPopup = () => "../../wxcomponents/privacy-popup/privacy-popup.js";
  4. const ProtocolDialog = () => "../../wxcomponents/protocol-dialog/protocol-dialog.js";
  5. const _sfc_main = {
  6. components: {
  7. PrivacyPopup,
  8. ProtocolDialog
  9. },
  10. data() {
  11. return {
  12. agreed: false,
  13. showProtocolDialog: false,
  14. protocolDialogTitle: "",
  15. protocolDialogContent: "",
  16. configData: [],
  17. // 存储 getConfig 返回的 result
  18. needPhone: false
  19. // 控制是否需要手机号授权
  20. };
  21. },
  22. computed: {
  23. logoImage() {
  24. const item = this.configData.find((i) => i.keyName === "logo_image");
  25. return item ? item.keyContent : "";
  26. },
  27. logoName() {
  28. const item = this.configData.find((i) => i.keyName === "logo_name");
  29. return item ? item.keyContent : "";
  30. }
  31. },
  32. onLoad() {
  33. this.getConfigData();
  34. },
  35. methods: {
  36. getConfigData() {
  37. this.$api("getConfig", {}, (res) => {
  38. if (res && res.success && Array.isArray(res.result)) {
  39. this.configData = res.result;
  40. }
  41. });
  42. },
  43. getConfigByKey(key) {
  44. const item = this.configData.find((i) => i.keyName === key);
  45. return item ? item.keyContent : "";
  46. },
  47. handleLogin() {
  48. if (!this.agreed) {
  49. common_vendor.index.showToast({
  50. title: "请阅读并勾选服务协议和隐私声明",
  51. icon: "none"
  52. });
  53. return;
  54. }
  55. this.$refs.privacyPopup.open();
  56. },
  57. handleCancel() {
  58. common_vendor.index.navigateBack();
  59. },
  60. handleAgreementChange(e) {
  61. if (this.agreed) {
  62. this.agreed = false;
  63. } else {
  64. this.agreed = true;
  65. }
  66. },
  67. openProtocol(type) {
  68. common_vendor.index.__f__("log", "at pages/index/index.vue:141", "Opening protocol:", type);
  69. common_vendor.index.__f__("log", "at pages/index/index.vue:142", "Current configData:", this.configData);
  70. let protocol = null;
  71. if (type === "privacy") {
  72. protocol = this.configData.find((i) => i.keyName === "user_ys");
  73. } else if (type === "service") {
  74. protocol = this.configData.find((i) => i.keyName === "user_xy");
  75. }
  76. common_vendor.index.__f__("log", "at pages/index/index.vue:149", "Found protocol:", protocol);
  77. this.protocolDialogTitle = protocol ? protocol.keyValue : type === "privacy" ? "隐私政策" : "服务协议";
  78. this.protocolDialogContent = protocol && protocol.keyContent ? protocol.keyContent : type === "privacy" ? '<div style="padding: 20rpx;">暂无隐私政策内容</div>' : '<div style="padding: 20rpx;">暂无服务协议内容</div>';
  79. this.showProtocolDialog = true;
  80. common_vendor.index.__f__("log", "at pages/index/index.vue:156", "Dialog state:", {
  81. title: this.protocolDialogTitle,
  82. content: this.protocolDialogContent,
  83. show: this.showProtocolDialog
  84. });
  85. },
  86. goToAdminLogin() {
  87. common_vendor.index.navigateTo({
  88. url: "/pages/component/admin_login"
  89. });
  90. },
  91. // 同意隐私政策
  92. handleAgreePrivacy() {
  93. common_vendor.index.showLoading({
  94. title: "登录中..."
  95. });
  96. let self = this;
  97. common_vendor.wx$1.login({
  98. success(res) {
  99. if (res.code) {
  100. self.$api("wxLogin", { code: res.code }, (res2) => {
  101. common_vendor.index.__f__("log", "at pages/index/index.vue:183", res2, "login");
  102. if (res2.code == 200) {
  103. common_vendor.index.hideLoading();
  104. common_vendor.index.setStorageSync("token", res2.result.token);
  105. common_vendor.index.setStorageSync("openid", res2.result.userInfo && res2.result.userInfo.appletOpenid);
  106. getApp().globalData.login_status = true;
  107. if (res2.result.userInfo) {
  108. const userInfo = res2.result.userInfo;
  109. common_vendor.index.__f__("log", "at pages/index/index.vue:192", userInfo, "userInfo");
  110. if (!userInfo.headImage || !userInfo.nickName) {
  111. common_vendor.index.navigateTo({
  112. url: "/pages/wxUserInfo"
  113. });
  114. } else {
  115. common_vendor.index.reLaunch({
  116. url: "/pages/component/home"
  117. });
  118. }
  119. } else {
  120. common_vendor.index.navigateTo({
  121. url: "/pages/wxUserInfo"
  122. });
  123. }
  124. }
  125. });
  126. } else {
  127. common_vendor.index.hideLoading();
  128. common_vendor.index.__f__("log", "at pages/index/index.vue:211", "登录失败!" + res.errMsg);
  129. }
  130. }
  131. });
  132. },
  133. // 拒绝隐私政策
  134. handleRejectPrivacy() {
  135. common_vendor.index.reLaunch({ url: "/pages/component/home" });
  136. },
  137. // 打开协议页面
  138. openProtocolPage(type) {
  139. this.openProtocol(type);
  140. },
  141. handleProtocolAgree() {
  142. this.showProtocolDialog = false;
  143. this.agreed = true;
  144. },
  145. handleProtocolReject() {
  146. this.showProtocolDialog = false;
  147. if (this.agreed) {
  148. this.agreed = false;
  149. }
  150. }
  151. }
  152. };
  153. if (!Array) {
  154. const _component_PrivacyPopup = common_vendor.resolveComponent("PrivacyPopup");
  155. const _component_ProtocolDialog = common_vendor.resolveComponent("ProtocolDialog");
  156. (_component_PrivacyPopup + _component_ProtocolDialog)();
  157. }
  158. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  159. return {
  160. a: $options.logoImage,
  161. b: common_vendor.t($options.logoName),
  162. c: common_vendor.o((...args) => $options.handleLogin && $options.handleLogin(...args)),
  163. d: common_vendor.o((...args) => $options.handleCancel && $options.handleCancel(...args)),
  164. e: $data.agreed,
  165. f: common_vendor.o(($event) => $options.openProtocol("service")),
  166. g: common_vendor.o(($event) => $options.openProtocol("privacy")),
  167. h: common_vendor.o((...args) => $options.handleAgreementChange && $options.handleAgreementChange(...args)),
  168. i: common_vendor.sr("privacyPopup", "1cf27b2a-0"),
  169. j: common_vendor.o($options.handleAgreePrivacy),
  170. k: common_vendor.o($options.handleRejectPrivacy),
  171. l: common_vendor.o($options.openProtocol),
  172. m: common_vendor.p({
  173. needPhone: $data.needPhone
  174. }),
  175. n: common_vendor.sr("protocolDialog", "1cf27b2a-1"),
  176. o: common_vendor.o(($event) => $data.showProtocolDialog = false),
  177. p: common_vendor.o($options.handleProtocolAgree),
  178. q: common_vendor.o($options.handleProtocolReject),
  179. r: common_vendor.p({
  180. show: $data.showProtocolDialog,
  181. title: $data.protocolDialogTitle,
  182. content: $data.protocolDialogContent
  183. })
  184. };
  185. }
  186. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1cf27b2a"]]);
  187. wx.createPage(MiniProgramPage);
  188. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map