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

142 lines
5.0 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
  4. const _sfc_main = {
  5. mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
  6. data() {
  7. return {
  8. user: {
  9. name: "赵莫艳",
  10. phone: "15888977617",
  11. avatar: "https://img1.baidu.com/it/u=1234567890,1234567890&fm=253&fmt=auto&app=138&f=JPEG?w=400&h=400",
  12. recycleCount: 2412,
  13. totalItems: 32,
  14. totalAmount: "8273.99",
  15. address: "海南省海口市秀英区秀英街道5单元183室"
  16. },
  17. statusBarHeight: 0
  18. };
  19. },
  20. computed: {
  21. navbarStyle() {
  22. return `padding-top: ${this.statusBarHeight}px;`;
  23. }
  24. },
  25. onLoad(options) {
  26. common_vendor.index.getSystemInfo({
  27. success: (res) => {
  28. this.statusBarHeight = res.statusBarHeight || 20;
  29. }
  30. });
  31. const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel();
  32. if (eventChannel) {
  33. eventChannel.on("userDetail", (user) => {
  34. this.user = Object.assign({}, this.user, user);
  35. if (user.id) {
  36. this.$api && this.$api("getUserOrderNum", { userId: user.id }, (res) => {
  37. if (res && res.code === 200 && res.result) {
  38. this.user.recycleCount = res.result.unit_num;
  39. this.user.totalItems = res.result.sum;
  40. this.user.totalAmount = res.result.order_money;
  41. }
  42. });
  43. this.$api && this.$api("getAddressList", { userId: user.id }, (res) => {
  44. if (res && res.code === 200 && Array.isArray(res.result)) {
  45. const defaultAddr = res.result.find((addr) => addr.defaultFlag === "Y");
  46. if (defaultAddr) {
  47. this.user.address = defaultAddr.address;
  48. }
  49. }
  50. });
  51. }
  52. });
  53. }
  54. },
  55. methods: {
  56. goBack() {
  57. common_vendor.index.navigateBack();
  58. },
  59. blockUser() {
  60. if (!this.user.id)
  61. return;
  62. this.$api("blackUser", { userId: this.user.id }, (res) => {
  63. if (res && res.code === 200) {
  64. common_vendor.index.showToast({ title: "已拉黑", icon: "success" });
  65. this.user.blocked = true;
  66. } else {
  67. common_vendor.index.showToast({ title: res.msg || "拉黑失败", icon: "none" });
  68. }
  69. });
  70. },
  71. upgradeUser() {
  72. if (!this.user.id)
  73. return;
  74. this.$api("upgrade", { userId: this.user.id }, (res) => {
  75. if (res && res.code === 200) {
  76. common_vendor.index.showToast({ title: "已升级为推广官", icon: "success" });
  77. this.user.role = "推广官";
  78. } else {
  79. common_vendor.index.showToast({ title: res.msg || "升级失败", icon: "none" });
  80. }
  81. });
  82. },
  83. viewOrders() {
  84. common_vendor.index.navigateTo({
  85. url: "/pages/manager/order?historyOrder=true&userId=" + this.user.id
  86. });
  87. },
  88. unblockUser() {
  89. common_vendor.index.showToast({ title: "已解除拉黑", icon: "none" });
  90. this.user.blocked = false;
  91. },
  92. refreshData() {
  93. },
  94. async onRefresh() {
  95. await this.refreshData && this.refreshData();
  96. }
  97. },
  98. onPullDownRefresh() {
  99. this.refreshData && this.refreshData();
  100. common_vendor.index.stopPullDownRefresh();
  101. }
  102. };
  103. if (!Array) {
  104. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  105. _easycom_uni_icons2();
  106. }
  107. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  108. if (!Math) {
  109. _easycom_uni_icons();
  110. }
  111. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  112. return common_vendor.e({
  113. a: common_vendor.p({
  114. type: "left",
  115. size: "20"
  116. }),
  117. b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
  118. c: $data.user.role === "推广官"
  119. }, $data.user.role === "推广官" ? {} : {}, {
  120. d: $data.user.blocked
  121. }, $data.user.blocked ? {} : {}, {
  122. e: common_vendor.t($data.user.name),
  123. f: common_vendor.t($data.user.phone),
  124. g: $data.user.avatar,
  125. h: common_vendor.t($data.user.recycleCount),
  126. i: common_vendor.t($data.user.totalItems),
  127. j: common_vendor.t($data.user.totalAmount),
  128. k: common_vendor.t($data.user.address),
  129. l: common_vendor.o((...args) => $options.viewOrders && $options.viewOrders(...args)),
  130. m: $data.user.blocked
  131. }, $data.user.blocked ? {
  132. n: common_vendor.o((...args) => $options.unblockUser && $options.unblockUser(...args))
  133. } : common_vendor.e({
  134. o: common_vendor.o((...args) => $options.blockUser && $options.blockUser(...args)),
  135. p: $data.user.role !== "推广官"
  136. }, $data.user.role !== "推广官" ? {
  137. q: common_vendor.o((...args) => $options.upgradeUser && $options.upgradeUser(...args))
  138. } : {}));
  139. }
  140. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-06a2669a"]]);
  141. wx.createPage(MiniProgramPage);
  142. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/manager/user-detail.js.map