goods.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const api_order = require("../api/order.js");
  4. const api_live = require("../api/live.js");
  5. const common_assets = require("../common/assets.js");
  6. const popupBottom = () => "../components/px-popup-bottom/px-popup-bottom.js";
  7. const _sfc_main = {
  8. components: {
  9. popupBottom
  10. },
  11. data() {
  12. return {
  13. totalNum: 1,
  14. orderKey: null,
  15. type: null,
  16. liveOrderList: [],
  17. //下订单的 不在这个页面
  18. liveId: null,
  19. // storeId:uni.setStorageSync("storeId"),
  20. serviceList: ["免邮发货", "药师服务", "隐私保护"],
  21. editShow: false,
  22. productId: null,
  23. goosDetail: {},
  24. //商品详情
  25. loadding: true,
  26. buyText: "立即购买",
  27. showStorePicker: false,
  28. goodsNum: 0,
  29. //商品选择数量
  30. productValueSelect: {
  31. price: 0,
  32. serviceFee: 0
  33. },
  34. attrs: [],
  35. values: [],
  36. stores: [],
  37. storeNames: [],
  38. storeIdx: 0,
  39. storeName: "",
  40. product: {
  41. price: 0,
  42. otPrice: 0
  43. },
  44. showModal: false,
  45. // 当前轮播的图片
  46. activeBanner: 1,
  47. // 购物车数量
  48. cartCount: 0,
  49. // 规格弹窗
  50. specVisible: false,
  51. // 规格数量
  52. specNum: 1,
  53. config: null,
  54. showServiceFee: false,
  55. selectVal: "",
  56. // 链接带的storeId
  57. urlStoreId: void 0,
  58. // 所选规格门店店铺价格
  59. storePriceList: [],
  60. // 所选店铺
  61. storeSelectInfo: {},
  62. // 保存选的规格
  63. choseSpecSubIndex: 0,
  64. choseSpecIndex: 0
  65. };
  66. },
  67. onLoad(options) {
  68. if (options.productId) {
  69. this.productId = options.productId;
  70. console.log("接收到的productId:", this.productId);
  71. }
  72. this.liveId = options.liveId;
  73. },
  74. mounted() {
  75. this.getliveGoods();
  76. var userInfo = common_vendor.index.getStorageSync("userInfo");
  77. console.log("之前的数据在这里", userInfo);
  78. },
  79. onShow() {
  80. },
  81. methods: {
  82. // 获得key
  83. getKey() {
  84. api_order.liveOrderKey().then(
  85. (res) => {
  86. if (res.code == 200) {
  87. console.log("下订单的key>>>>", res);
  88. this.orderKey = res.orderKey;
  89. console.log("key>>>>", this.orderKey);
  90. common_vendor.index.navigateTo({
  91. url: "/pages_shop/confirmCreateOrder?orderKey=" + this.orderKey + "&liveId=" + this.liveId + "&productId=" + this.productId + "&totalNum=" + this.totalNum + "&price=" + this.goosDetail.price
  92. });
  93. } else {
  94. common_vendor.index.showToast({
  95. title: res.msg,
  96. icon: "none"
  97. });
  98. }
  99. },
  100. (rej) => {
  101. }
  102. );
  103. },
  104. // 点击取消/支付订单
  105. operateOrder(type) {
  106. let orderId = this.liveOrderList;
  107. console.log("orderId>>", orderId);
  108. },
  109. // 选择商品数量
  110. goodsNumChange(e) {
  111. console.log("当前选择商品数量为: " + e.value);
  112. this.totalNum = e.value;
  113. },
  114. // 提交
  115. submit() {
  116. this.specVisible = false;
  117. this.getKey();
  118. },
  119. // 加入购物车
  120. addCart(type) {
  121. this.type = type;
  122. this.specVisible = true;
  123. },
  124. // doAddCart(type) {
  125. // if (this.specNum == 0) {
  126. // uni.showToast({
  127. // icon: 'none',
  128. // title: "库存不足",
  129. // });
  130. // return;
  131. // }
  132. // var isBuy = type == "buy" ? 1 : 0;
  133. // let data = {
  134. // isBuy: isBuy,
  135. // cartNum: this.specNum,
  136. // productId: this.productValueSelect.productId,
  137. // attrValueId: this.productValueSelect.id
  138. // };
  139. // addCart(data).then(
  140. // res => {
  141. // if (res.code == 200) {
  142. // if (type == "buy") {
  143. // const selectCarts = [{
  144. // storeId: this.storeId,
  145. // data: {
  146. // type: this.type,
  147. // cartIds: res.id,
  148. // }
  149. // }]
  150. // uni.navigateTo({
  151. // url: '/pages/shopping/confirmOrder?type=' + this.type + '&orderType=' +
  152. // this.orderType + '&confirmParam=' + encodeURIComponent(JSON.stringify(
  153. // selectCarts))
  154. // })
  155. // } else {
  156. // this.getCartCount()
  157. // uni.showToast({
  158. // icon: 'success',
  159. // title: "添加成功",
  160. // });
  161. // }
  162. // } else {
  163. // uni.showToast({
  164. // icon: 'none',
  165. // title: res.msg,
  166. // });
  167. // this.getProductDetails()
  168. // }
  169. // },
  170. // rej => {}
  171. // );
  172. // },
  173. // 跳转页面
  174. navgetTo(url) {
  175. console.log("跳转");
  176. common_vendor.index.navigateTo({
  177. url
  178. });
  179. },
  180. openEditMoney() {
  181. this.editShow = true;
  182. },
  183. //商品详情
  184. getliveGoods() {
  185. api_live.liveGoodsDetail(this.productId).then(
  186. (res) => {
  187. if (res.code == 200) {
  188. console.log("小黄车 商品详情>>>>", res);
  189. this.goosDetail = res.data;
  190. } else {
  191. common_vendor.index.showToast({
  192. title: res.msg,
  193. icon: "none"
  194. });
  195. }
  196. },
  197. (rej) => {
  198. }
  199. );
  200. }
  201. }
  202. };
  203. if (!Array) {
  204. const _component_uni_badge = common_vendor.resolveComponent("uni-badge");
  205. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  206. const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
  207. const _easycom_u_number_box2 = common_vendor.resolveComponent("u-number-box");
  208. const _component_popupBottom = common_vendor.resolveComponent("popupBottom");
  209. (_component_uni_badge + _easycom_u_icon2 + _easycom_u_popup2 + _easycom_u_number_box2 + _component_popupBottom)();
  210. }
  211. const _easycom_u_icon = () => "../uni_modules/uview-plus/components/u-icon/u-icon.js";
  212. const _easycom_u_popup = () => "../uni_modules/uview-plus/components/u-popup/u-popup.js";
  213. const _easycom_u_number_box = () => "../uni_modules/uview-plus/components/u-number-box/u-number-box.js";
  214. if (!Math) {
  215. (_easycom_u_icon + _easycom_u_popup + _easycom_u_number_box)();
  216. }
  217. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  218. var _a;
  219. return common_vendor.e({
  220. a: $data.goosDetail.imgUrl,
  221. b: $data.product.productType == 2
  222. }, $data.product.productType == 2 ? {} : {}, {
  223. c: common_vendor.t($data.goosDetail.price),
  224. d: common_vendor.t($data.goosDetail.otPrice),
  225. e: common_vendor.t($data.goosDetail.sales),
  226. f: common_vendor.f($data.serviceList, (item, index, i0) => {
  227. return {
  228. a: common_vendor.t(item),
  229. b: index
  230. };
  231. }),
  232. g: common_assets._imports_0$9,
  233. h: common_assets._imports_1$6,
  234. i: common_vendor.o(($event) => $options.openEditMoney()),
  235. j: $data.editShow
  236. }, $data.editShow ? {
  237. k: common_vendor.o(($event) => _ctx.cancelEditMoney()),
  238. l: common_vendor.o(($event) => _ctx.cancelEditMoney()),
  239. m: common_vendor.o(($event) => _ctx.cancelEditMoney())
  240. } : {}, {
  241. n: common_vendor.t(),
  242. o: common_vendor.o(($event) => $options.navgetTo("/pages_shop/store?liveId=" + $data.liveId)),
  243. p: $data.product.description,
  244. q: common_assets._imports_2$5,
  245. r: common_vendor.o(($event) => $options.navgetTo("./store")),
  246. s: common_assets._imports_3$1,
  247. t: common_vendor.p({
  248. size: "small",
  249. text: $data.cartCount,
  250. absolute: "rightTop",
  251. type: "error"
  252. }),
  253. v: common_vendor.o(($event) => $options.navgetTo("./cart")),
  254. w: common_vendor.o(($event) => $options.addCart("cart")),
  255. x: common_vendor.t($data.buyText),
  256. y: common_vendor.o(($event) => $options.addCart("buy")),
  257. z: ((_a = $data.goosDetail) == null ? void 0 : _a.imgUrl) || _ctx.$img.img,
  258. A: common_vendor.t($data.goosDetail.productName),
  259. B: common_vendor.t($data.goosDetail.price ? $data.goosDetail.price.toFixed(2) : "0.00"),
  260. C: common_vendor.t($data.goosDetail.sales),
  261. D: common_vendor.f($data.storePriceList, (item, index, i0) => {
  262. return {
  263. a: common_vendor.t(item.price.toFixed(2)),
  264. b: common_vendor.t(_ctx.utils.formatSalesNum(item.sales)),
  265. c: common_vendor.t(item.storeName),
  266. d: "14e5f6c8-3-" + i0 + ",14e5f6c8-2",
  267. e: index,
  268. f: common_vendor.n($data.productValueSelect.storeId == item.storeId ? "item hover" : "item"),
  269. g: common_vendor.o(($event) => _ctx.pickerStore(item, index), index)
  270. };
  271. }),
  272. E: common_vendor.p({
  273. name: "arrow-right",
  274. color: "#000",
  275. size: "14"
  276. }),
  277. F: common_vendor.p({
  278. show: $data.showStorePicker,
  279. round: 16,
  280. mode: "bottom"
  281. }),
  282. G: common_vendor.o($options.goodsNumChange),
  283. H: common_vendor.o(($event) => $data.goodsNum = $event),
  284. I: common_vendor.p({
  285. bgColor: "#ececec",
  286. modelValue: $data.goodsNum
  287. }),
  288. J: common_vendor.o((...args) => $options.submit && $options.submit(...args)),
  289. K: common_vendor.sr("popup", "14e5f6c8-1"),
  290. L: common_vendor.p({
  291. visible: $data.specVisible,
  292. title: " ",
  293. radius: "32",
  294. maxHeight: "800"
  295. })
  296. });
  297. }
  298. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  299. wx.createPage(MiniProgramPage);