index.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const utils_system = require("../../utils/system.js");
  4. const pagesOne_winner_utils_source = require("./utils/source.js");
  5. const services_ams = require("../../services/ams.js");
  6. if (!Array) {
  7. const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
  8. const _easycom_wd_gap2 = common_vendor.resolveComponent("wd-gap");
  9. (_easycom_wd_icon2 + _easycom_wd_gap2)();
  10. }
  11. const _easycom_wd_icon = () => "../../node-modules/wot-design-uni/components/wd-icon/wd-icon.js";
  12. const _easycom_wd_gap = () => "../../node-modules/wot-design-uni/components/wd-gap/wd-gap.js";
  13. if (!Math) {
  14. (_easycom_wd_icon + _easycom_wd_gap + PhotoExamplePopup + UploadReceptPopop + WinRecordPopup + UploadRecordPopup + ActivityDescPopup)();
  15. }
  16. const PhotoExamplePopup = () => "./components/photoExamplePopup.js";
  17. const UploadReceptPopop = () => "./components/uploadReceptPopop.js";
  18. const WinRecordPopup = () => "./components/winRecordPopup.js";
  19. const UploadRecordPopup = () => "./components/uploadRecordPopup.js";
  20. const ActivityDescPopup = () => "./components/activityDescPopup.js";
  21. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  22. __name: "index",
  23. setup(__props) {
  24. let showExample = common_vendor.ref(false);
  25. let showUpload = common_vendor.ref(false);
  26. let showWiner = common_vendor.ref(false);
  27. let showRecord = common_vendor.ref(false);
  28. let showDesc = common_vendor.ref(false);
  29. const appid = common_vendor.index.getStorageSync("appid");
  30. const backImage = common_vendor.ref("");
  31. let aData = common_vendor.reactive({ discounts: [] });
  32. let list = common_vendor.ref([]);
  33. const openid = common_vendor.index.getStorageSync("openid");
  34. common_vendor.computed(() => {
  35. return aData.authCheck.includes("2") ? true : false;
  36. });
  37. const getList = () => {
  38. services_ams.getActivity(appid).then((res) => {
  39. aData = res.data[0] || {};
  40. aData.authCheck = aData.authCheck.split(",");
  41. list.value = aData.discounts.map((item) => {
  42. return {
  43. ...item,
  44. checked: false
  45. };
  46. });
  47. common_vendor.index.setStorageSync("activityData", JSON.stringify(aData));
  48. backImage.value = res.data[0].activityImage;
  49. aData.description = aData.description.split("\n");
  50. }).catch((err) => {
  51. console.log(err);
  52. });
  53. };
  54. const rewardData = common_vendor.ref([]);
  55. const getRewardList = () => {
  56. console.log("openid", openid);
  57. services_ams.rewardList({ openid, marketingActivityId: aData.id }).then((res) => {
  58. rewardData.value = res.rows;
  59. });
  60. };
  61. const showUploadRecord = () => {
  62. getRewardList();
  63. showRecord.value = true;
  64. };
  65. const winnerData = common_vendor.ref([]);
  66. const getWinnerList = () => {
  67. services_ams.auditSuccessList({ openid, marketingActivityId: aData.id }).then(
  68. (res) => {
  69. winnerData.value = res.rows;
  70. }
  71. );
  72. };
  73. const showWinerRecord = () => {
  74. getWinnerList();
  75. showWiner.value = true;
  76. };
  77. const onBack = () => {
  78. common_vendor.index.navigateBack({ delta: 1 });
  79. };
  80. const handledUpload = () => {
  81. const location = JSON.parse(common_vendor.index.getStorageSync("location"));
  82. if (!aData.authCheck.includes("2") || location.latitude) {
  83. showUpload.value = true;
  84. return;
  85. }
  86. common_vendor.index.getSetting({
  87. success: (res) => {
  88. if (!res.authSetting["scope.address"]) {
  89. common_vendor.index.authorize({
  90. scope: "scope.address",
  91. success() {
  92. console.log("1111111111111111111");
  93. },
  94. fail() {
  95. common_vendor.index.showModal({
  96. title: "提示",
  97. content: "您拒绝了地址授权,请手动开启",
  98. success: () => {
  99. common_vendor.index.openSetting();
  100. }
  101. });
  102. }
  103. });
  104. } else {
  105. common_vendor.index.getLocation({
  106. type: "wgs84",
  107. success: function(res2) {
  108. console.log("---------------------------", res2);
  109. console.log("当前位置的经度:" + res2.longitude);
  110. console.log("当前位置的纬度:" + res2.latitude);
  111. common_vendor.index.setStorageSync("location", JSON.stringify(res2));
  112. setTimeout(() => {
  113. showUpload.value = true;
  114. }, 500);
  115. },
  116. fail(error) {
  117. common_vendor.index.showToast({
  118. title: "请勿频繁调用!",
  119. icon: "none"
  120. });
  121. console.log("失败", error);
  122. }
  123. });
  124. }
  125. }
  126. });
  127. };
  128. common_vendor.onShow(() => {
  129. getList();
  130. });
  131. common_vendor.ref(0);
  132. common_vendor.onLoad(() => {
  133. });
  134. return (_ctx, _cache) => {
  135. return {
  136. a: common_vendor.unref(utils_system.getStatusBarHeight)() + "px",
  137. b: common_vendor.o(onBack),
  138. c: common_vendor.p({
  139. name: "thin-arrow-left",
  140. size: "44rpx",
  141. color: "#000"
  142. }),
  143. d: common_vendor.unref(utils_system.getNavBarPaddingTop)() + "px",
  144. e: backImage.value,
  145. f: common_vendor.o(($event) => common_vendor.isRef(showDesc) ? showDesc.value = true : showDesc = true),
  146. g: common_vendor.unref(pagesOne_winner_utils_source.imgObj).rule,
  147. h: common_vendor.unref(pagesOne_winner_utils_source.imgObj).record,
  148. i: common_vendor.o(showWinerRecord),
  149. j: common_vendor.unref(pagesOne_winner_utils_source.imgObj).photo,
  150. k: common_vendor.o(($event) => common_vendor.isRef(showExample) ? showExample.value = true : showExample = true),
  151. l: common_vendor.unref(pagesOne_winner_utils_source.imgObj).book,
  152. m: common_vendor.o(showUploadRecord),
  153. n: common_vendor.unref(pagesOne_winner_utils_source.gifObj).pointer,
  154. o: common_vendor.o(handledUpload),
  155. p: common_vendor.t(common_vendor.unref(aData).startTime),
  156. q: common_vendor.t(common_vendor.unref(aData).endTime),
  157. r: common_vendor.f(common_vendor.unref(list), (item, k0, i0) => {
  158. return {
  159. a: common_vendor.t(item.cashbackAmount),
  160. b: common_vendor.t(item.thresholdAmount),
  161. c: common_vendor.t(item.cashbackAmount),
  162. d: item.id
  163. };
  164. }),
  165. s: common_vendor.p({
  166. ["bg-color"]: "transparent"
  167. }),
  168. t: common_vendor.o(($event) => common_vendor.isRef(showExample) ? showExample.value = $event : showExample = $event),
  169. v: common_vendor.p({
  170. show: common_vendor.unref(showExample)
  171. }),
  172. w: common_vendor.unref(aData).id,
  173. x: common_vendor.o(($event) => common_vendor.isRef(showUpload) ? showUpload.value = $event : showUpload = $event),
  174. y: common_vendor.p({
  175. list: common_vendor.unref(list),
  176. id: common_vendor.unref(aData).id,
  177. show: common_vendor.unref(showUpload)
  178. }),
  179. z: common_vendor.o(($event) => common_vendor.isRef(showWiner) ? showWiner.value = $event : showWiner = $event),
  180. A: common_vendor.p({
  181. list: winnerData.value,
  182. show: common_vendor.unref(showWiner)
  183. }),
  184. B: common_vendor.o(($event) => common_vendor.isRef(showRecord) ? showRecord.value = $event : showRecord = $event),
  185. C: common_vendor.p({
  186. list: rewardData.value,
  187. show: common_vendor.unref(showRecord)
  188. }),
  189. D: common_vendor.o(($event) => common_vendor.isRef(showDesc) ? showDesc.value = $event : showDesc = $event),
  190. E: common_vendor.p({
  191. description: common_vendor.unref(aData).description,
  192. show: common_vendor.unref(showDesc)
  193. })
  194. };
  195. };
  196. }
  197. });
  198. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3457e999"]]);
  199. wx.createPage(MiniProgramPage);