mall-detail.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>商品详情-商城-创业帮</title>
  6. <meta name="keywords" content="商品详情-商城-创业帮">
  7. <meta name="description" content="商品详情-商城-创业帮">
  8. <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  11. <meta content="telephone=no" name="format-detection">
  12. <meta content="email=no" name="format-detection">
  13. <meta name="apple-mobile-web-app-title" content="商品详情-商城-创业帮">
  14. <meta http-equiv="Cache-Control" content="no-siteapp">
  15. <link rel="stylesheet" href="./static/css/main.css">
  16. <style>
  17. /* 首页*/
  18. .banner .van-skeleton__title{height:3rem;border-radius:10px;}
  19. .banner1 .van-skeleton__title{height:5rem;border-radius:15px;}
  20. .indexicon{margin-top:50px;}
  21. .indexicon .van-skeleton__content{display:flex; justify-content:space-between;}
  22. .indexicon .van-skeleton__content .van-skeleton__row{display:inline-block; width:1.2rem !important; height:1.2rem; margin-top:0 !important; border-radius:50%;}
  23. /* 商品详情*/
  24. .mall-skeleton-title .van-skeleton__title{height:9rem;border-radius:15px;}
  25. .mall-skeleton-text .van-skeleton__title{height:3rem;border-radius:15px;}
  26. .mall-skeleton .van-skeleton__title{height:10rem;border-radius:15px;}
  27. </style>
  28. <style>
  29. .mall-bottom{padding:0 .3733rem;height:54px;}
  30. .mall-bottom button{border-radius:999px !important; height:80% !important;}
  31. .van-sku-actions {padding:8px .3733rem 5px;}
  32. .van-button--large{height:43.2px !important; border-radius:999px !important;}
  33. </style>
  34. </head>
  35. <body class="bgcfff pt0" style="padding-top:0;">
  36. <div class="mall-detail" id="app">
  37. <van-skeleton class="mall-skeleton-title" title :row="0" title-width="100%" :loading="loading" style="margin-top:30px;"></van-skeleton>
  38. <van-skeleton class="mall-skeleton-text" title :row="0" title-width="100%" :loading="loading" style="margin-top:30px;"></van-skeleton>
  39. <van-skeleton class="mall-skeleton" title :row="0" title-width="100%" :loading="loading" style="margin-top:30px;"></van-skeleton>
  40. <div v-if="!loading">
  41. <van-sticky>
  42. <van-nav-bar class="user_rank_explan_title user_title_normal" title="商品详情" @click-left="goback" v-if="toptitleisshow" left-arrow>
  43. <template #left> <img src="./static/images/left.png" alt=""></template>
  44. </van-nav-bar>
  45. </van-sticky>
  46. <div class="mall-detail-img"><img class="fl" style="width:100%;" :src="product.DetailPicPath" fit="cover" v-cloak></div>
  47. <div class="pb16 pl16 pr16 bb8f7f7f7" v-cloak>
  48. <div class="f18 c333 b pb6">{{product.ProductName}}</div>
  49. <div class="f14 c999 pb8">{{product.Details}}</div>
  50. <div class="f18 more b">¥{{product.Price}}</div>
  51. </div>
  52. <div class="pt8 pb6 pl16 pr16">
  53. <div class="f12 b">商品详情</div>
  54. </div>
  55. <div class="mall-detail-c pl16 pr16" v-html="product.Contents"></div>
  56. <van-goods-action class="mall-bottom">
  57. <van-goods-action-button class="kxs-btn" type="default" color="#FFD500" style="color:#333;" text="立即购买" @click="onClickButton"></van-goods-action-button>
  58. </van-goods-action>
  59. <van-sku class="mall-sku-box" v-if="show" v-model="show" :start-sale-num="minbuycount" :sku="sku" ref="skuBox" :show-add-cart-btn="false" :goods="goods" :goods-id="goodsId" :quota="quota" :quota-used="quotaUsed" :hide-stock="sku.hide_stock" :message-config="messageConfig" :custom-stepper-config="customStepperConfig" @buy-clicked="onBuyClicked" @add-cart="onAddCartClicked" @sku-selected="onSkuSelected">
  60. <template #sku-header-extra>
  61. <div class="sku-title f16 c333 b abs line2">{{product.ProductName}}</div>
  62. </template>
  63. <template #sku-header-price><span class="f16 more b">¥{{sku.price | tofixed2}}</span></template>
  64. <template #sku-messages>
  65. <div class="f12 c333 tr pr16">合计:<span class="f16 more b">¥{{totalPrice}}</span></div>
  66. </template>
  67. </van-sku>
  68. </div>
  69. </div>
  70. <script src="./static/js/klm-vv.min.js"></script>
  71. <script src="./static/js/appfunc.min.js"></script>
  72. <script src="./static/js/klm-axios-config.js"></script>
  73. <script src="./static/js/publicfn.js"></script>
  74. <script>
  75. function OnStart(){
  76. app.getmalldetailinfo();
  77. };
  78. // 通过 CDN 引入时不会自动注册 Lazyload 组件
  79. // 可以通过下面的方式手动注册
  80. Vue.use(vant.Lazyload);
  81. // 在 #app 标签下渲染一个按钮组件
  82. let app = new Vue({
  83. el: '#app',
  84. data() {
  85. return {
  86. //- browsernum:'',
  87. loading:true,
  88. minbuycount:1,
  89. toptitleisshow,
  90. show: false,
  91. sku: {
  92. tree: [
  93. //- {
  94. //- k: '尺寸', // skuKeyName:规格类目名称
  95. //- k_s: 's1', // skuKeyStr:sku 组合列表(下方 list)中当前类目对应的 key 值,value 值会是从属于当前类目的一个规格值 id
  96. //- v: [
  97. //- {
  98. //- id: '1', // skuValueId:规格值 id
  99. //- name: 'S', // skuValueName:规格值名称
  100. //- },
  101. //- {
  102. //- id: '2',
  103. //- name: 'M',
  104. //- },
  105. //- {
  106. //- id: '3',
  107. //- name: 'L',
  108. //- },
  109. //- {
  110. //- id: '4',
  111. //- name: 'XL',
  112. //- },
  113. //- {
  114. //- id: '5',
  115. //- name: 'XXL',
  116. //- }
  117. //- ],
  118. //- //- largeImageMode: true, // 是否展示大图模式
  119. //- },
  120. //- {
  121. //- k: '颜色', // skuKeyName:规格类目名称
  122. //- k_s: 's2', // skuKeyStr:sku 组合列表(下方 list)中当前类目对应的 key 值,value 值会是从属于当前类目的一个规格值 id
  123. //- v: [
  124. //- {
  125. //- id: '1', // skuValueId:规格值 id
  126. //- name: '黑色', // skuValueName:规格值名称
  127. //- imgUrl: './temp/product1.png', // 规格类目图片,只有第一个规格类目可以定义图片
  128. //- previewImgUrl: './temp/product1.png', // 用于预览显示的规格类目图片
  129. //- },
  130. //- {
  131. //- id: '2',
  132. //- name: '白色',
  133. //- imgUrl: './temp/product2.png',
  134. //- previewImgUrl: './temp/product2.png',
  135. //- },
  136. //- {
  137. //- id: '3',
  138. //- name: '红色',
  139. //- imgUrl: './temp/product3.png',
  140. //- previewImgUrl: './temp/product3.png',
  141. //- }
  142. //- ],
  143. //- //- largeImageMode: true, // 是否展示大图模式
  144. //- },
  145. ],
  146. // 所有 sku 的组合列表,比如红色、M 码为一个 sku 组合,红色、S 码为另一个组合
  147. list: [
  148. //- {
  149. //- id: 2259, // skuId
  150. //- s1: '1', // 规格类目 k_s 为 s1 的对应规格值 id
  151. //- s2: '1', // 规格类目 k_s 为 s1 的对应规格值 id
  152. //- s3: '2',
  153. //- price: 200, // 价格(单位元)
  154. //- stock_num: 10 // 当前 sku 组合对应的库存
  155. //- },
  156. //- {
  157. //- id: 22329, // skuId
  158. //- s1: '1', // 规格类目 k_s 为 s1 的对应规格值 id
  159. //- s2: '2', // 规格类目 k_s 为 s1 的对应规格值 id
  160. //- s3: '1',
  161. //- price: 200, // 价格(单位元)
  162. //- stock_num: 110 // 当前 sku 组合对应的库存
  163. //- },
  164. //- {
  165. //- id: 22329, // skuId
  166. //- s1: '5', // 规格类目 k_s 为 s1 的对应规格值 id
  167. //- s2: '3', // 规格类目 k_s 为 s1 的对应规格值 id
  168. //- price: 200, // 价格(单位元)
  169. //- stock_num: 110 // 当前 sku 组合对应的库存
  170. //- },
  171. //- {
  172. //- id: 22329, // skuId
  173. //- s1: '2', // 规格类目 k_s 为 s1 的对应规格值 id
  174. //- s2: '1', // 规格类目 k_s 为 s1 的对应规格值 id
  175. //- price: 200, // 价格(单位元)
  176. //- stock_num: 110 // 当前 sku 组合对应的库存
  177. //- },
  178. //- {
  179. //- id: 22329, // skuId
  180. //- s1: '2', // 规格类目 k_s 为 s1 的对应规格值 id
  181. //- s2: '3', // 规格类目 k_s 为 s1 的对应规格值 id
  182. //- price: 200, // 价格(单位元)
  183. //- stock_num: 110 // 当前 sku 组合对应的库存
  184. //- },
  185. //- {
  186. //- id: 22329, // skuId
  187. //- s1: '3', // 规格类目 k_s 为 s1 的对应规格值 id
  188. //- s2: '2', // 规格类目 k_s 为 s1 的对应规格值 id
  189. //- price: 100, // 价格(单位元)
  190. //- stock_num: 10 // 当前 sku 组合对应的库存
  191. //- },
  192. //- {
  193. //- id: 22329, // skuId
  194. //- s1: '3', // 规格类目 k_s 为 s1 的对应规格值 id
  195. //- s2: '1', // 规格类目 k_s 为 s1 的对应规格值 id
  196. //- price: 100, // 价格(单位元)
  197. //- stock_num: 0 // 当前 sku 组合对应的库存
  198. //- }
  199. ],
  200. price: '', // 默认价格(单位元)
  201. stock_num: 227, // 商品总库存
  202. collection_id: 2261, // 无规格商品 skuId 取 collection_id,否则取所选 sku 组合对应的 id
  203. none_sku: false, // 是否无规格商品
  204. //- messages: [
  205. //- {
  206. //- // 商品留言
  207. //- datetime: '0', // 留言类型为 time 时,是否含日期。'1' 表示包含
  208. //- multiple: '0', // 留言类型为 text 时,是否多行文本。'1' 表示多行
  209. //- name: '留言', // 留言名称
  210. //- type: 'text', // 留言类型,可选: id_no(身份证), text, tel, date, time, email
  211. //- required: '1', // 是否必填 '1' 表示必填
  212. //- placeholder: '', // 可选值,占位文本
  213. //- extraDesc: '' // 可选值,附加描述文案
  214. //- }
  215. //- ],
  216. hide_stock: true // 是否隐藏剩余库存
  217. },
  218. goodsId: 1,
  219. quota: 0,
  220. quotaUsed: 0,
  221. goods: {
  222. // 默认商品 sku 缩略图
  223. picture: './static/images/payment-type-1.png',
  224. },
  225. messageConfig: {
  226. //- // 图片上传回调,需要返回一个promise,promise正确执行的结果需要是一个图片url
  227. //- uploadImg: () => {
  228. //- return new Promise((resolve) => {
  229. //- setTimeout(() => resolve('https://img01.yzcdn.cn/upload_files/2017/02/21/FjKTOxjVgnUuPmHJRdunvYky9OHP.jpg!100x100.jpg'), 1000);
  230. //- });
  231. //- },
  232. //- // 可选项,自定义图片上传逻辑,使用此选项时,会禁用原生图片选择
  233. //- customUpload: () => {
  234. //- return new Promise((resolve) => {
  235. //- setTimeout(() => {
  236. //- resolve('https://img01.yzcdn.cn/vant/leaf.jpg');
  237. //- }, 1000);
  238. //- });
  239. //- },
  240. //- // 最大上传体积 (MB)
  241. //- uploadMaxSize: 3,
  242. //- // placeholder 配置
  243. //- placeholderMap: {
  244. //- text: 'xxx',
  245. //- tel: 'xxx',
  246. //- },
  247. //- // 初始留言信息
  248. //- // 键:留言 name
  249. //- // 值:留言内容
  250. //- initialMessages: {
  251. //- 留言: '留言信息'
  252. //- }
  253. },
  254. customStepperConfig:{
  255. // 自定义限购文案
  256. //- quotaText: '每次限购xxx件',
  257. // 自定义步进器超过限制时的回调
  258. //- handleOverLimit: (data) => {
  259. //- const { action, limitType, quota, quotaUsed, startSaleNum } = data;
  260. //- if (action === 'minus') {
  261. //- vant.Toast(startSaleNum > 1 ? `${startSaleNum}件起售` : '至少选择一件商品');
  262. //- } else if (action === 'plus') {
  263. //- const { LIMIT_TYPE } = vant.Sku.skuConstants;
  264. //- if (limitType === LIMIT_TYPE.QUOTA_LIMIT) {
  265. //- let msg = `单次限购${quota}件`;
  266. //- if (quotaUsed > 0) msg += `,你已购买${quotaUsed}件`;
  267. //- vant.Toast(msg);
  268. //- } else {
  269. //- vant.Toast('库存不够了');
  270. //- }
  271. //- }
  272. //- },
  273. // 步进器变化的回调
  274. handleStepperChange: currentValue => {
  275. const data = this.$refs.skuBox.getSkuData().selectedSkuComb;
  276. //- 根据是否有规格匹配单位(基准单位为分,强制更改为元)
  277. if(this.sku.none_sku){
  278. if(data){
  279. this.totalPrice = ((data.price) * currentValue / 100).toFixed(2);
  280. }else{
  281. this.totalPrice = (this.sku.price * currentValue / 100).toFixed(2);
  282. }
  283. } else {
  284. if(data){
  285. this.totalPrice = ((data.price) * currentValue).toFixed(2);
  286. }else{
  287. this.totalPrice = (this.sku.price * currentValue).toFixed(2);
  288. }
  289. }
  290. this.nowSelectedNum = currentValue;
  291. },
  292. // 库存
  293. stockNum: 10000,
  294. // 格式化库存
  295. stockFormatter: stockNum => {},
  296. },
  297. product:{
  298. },
  299. totalPrice: 0,
  300. nowSelectedNum: 0,
  301. mallid:0,
  302. };
  303. },
  304. created() {
  305. //- this.browsernum = '1.5.0';
  306. this.getmalldetailinfo();
  307. },
  308. methods: {
  309. async getmalldetailinfo(){
  310. const Id = PublicLib.getCookieInfo('malldetailId');
  311. this.mallid = Id;
  312. this.goodsId = Number(Id);
  313. const res = await getRequest('api/v1/products/detail?t='+Math.random(6),JSON.stringify({Id}));
  314. if(res.status !== '1') return tips('获取商品详情失败,请重试!');
  315. res.data.DetailPicPath = res.data.DetailPicPath.length === 0 ? './static/images/payment-type-1.png' : res.data.DetailPicPath[0].Photo;
  316. if(res.data.NormJson.none_sku){
  317. res.data.NormJson.list =[];
  318. res.data.NormJson.tree =[];
  319. };
  320. this.goods.picture = res.data.DetailPicPath;
  321. this.product = res.data;
  322. this.sku.price = res.data.Price;
  323. this.sku = res.data.NormJson;
  324. if(this.sku.tree.length !== 0){
  325. this.sku.tree.forEach(item=>{
  326. item.largeImageMode = false
  327. });
  328. };
  329. //- 起购数量
  330. if(this.mallid === '8' || this.mallid === '9' || this.mallid === '10'){
  331. this.minbuycount = 1;
  332. }else if(this.mallid === '11'){
  333. this.minbuycount = 1;
  334. }else if(this.mallid === '14'){
  335. this.minbuycount = 2;
  336. }else if(this.mallid === '20'){
  337. this.minbuycount = 2;
  338. }else if(this.mallid === '15' || this.mallid === '29'){
  339. this.quota = 1;
  340. }else if(this.mallid === '27' || this.mallid === '28'){
  341. this.quota = 1;
  342. };
  343. //- 前端限制大小萌主
  344. if(this.mallid === '12' || this.mallid === '13'){
  345. if(res.data.NormJson.none_sku || res.data.NormJson.list[0].stock_num === 0){
  346. this.getmalldetailinfo();
  347. };
  348. };
  349. //- 骨架屏隐藏
  350. this.loading = false;
  351. },
  352. onClickButton() {
  353. if(this.mallid === '22'){
  354. return tips('名额已满,下期再见!')
  355. };
  356. this.totalPrice = 0;
  357. this.show = true;
  358. //- 根据是否有规格进行总价显示判断
  359. if(!this.nowSelectedNum){
  360. this.totalPrice = this.sku.none_sku ? this.sku.price : 0;
  361. };
  362. //- 起购价格
  363. //- if(this.browsernum !== '1.5.0'){
  364. //- if(this.mallid === '8' || this.mallid === '9' || this.mallid === '10'){
  365. //- this.totalPrice = 3 * this.sku.price;
  366. //- }else if(this.mallid === '11'){
  367. //- this.totalPrice = 2 * this.sku.price;
  368. //- };
  369. //- };
  370. if(this.mallid === '14'){
  371. this.totalPrice = 2 * this.sku.price;
  372. }else if(this.mallid === '20'){
  373. this.totalPrice = 2 * this.sku.price;
  374. };
  375. },
  376. onSkuSelected(skuValue) {
  377. console.log(skuValue);
  378. if(this.mallid === '20' && this.nowSelectedNum < 2){
  379. this.nowSelectedNum = 2;
  380. }else{
  381. this.nowSelectedNum = 1;
  382. }
  383. //- if(this.browsernum !== '1.5.0'){
  384. //- if(this.mallid === '12'){
  385. //- this.minbuycount = 1;
  386. //- this.quota = 1;
  387. //- this.nowSelectedNum = 1;
  388. //- if(skuValue.selectedSkuComb.price === 300){
  389. //- this.minbuycount = 50;
  390. //- this.quota = 50;
  391. //- this.nowSelectedNum = 50;
  392. //- }else{
  393. //- this.minbuycount = 75;
  394. //- this.quota = 75;
  395. //- this.nowSelectedNum = 75;
  396. //- };
  397. //- }else
  398. //- if(this.mallid === '13'){
  399. //- if(skuValue.selectedSkuComb.price === 300){
  400. //- this.minbuycount = 200;
  401. //- this.quota = 200;
  402. //- this.nowSelectedNum = 200;
  403. //- }else if(skuValue.selectedSkuComb.price === 200){
  404. //- this.minbuycount = 300;
  405. //- this.quota = 300;
  406. //- this.nowSelectedNum = 300;
  407. //- }else{
  408. //- this.nowSelectedNum = 1;
  409. //- setTimeout(() =>{
  410. //- this.quota = 1;
  411. //- },10)
  412. //- }
  413. //- };
  414. //- }
  415. //- 规格变化后,显示总价
  416. const price = skuValue.selectedSkuComb !== null ? skuValue.selectedSkuComb.price: 0;
  417. this.sku.price = price;
  418. if(this.nowSelectedNum > 0){
  419. this.totalPrice = price ? (price * this.nowSelectedNum).toFixed(2) : 0;
  420. }else{
  421. this.totalPrice = (price).toFixed(2);
  422. };
  423. setTimeout(()=>{
  424. this.quota = 0;
  425. },0);
  426. },
  427. //- 添加购物车(暂时没有该功能)
  428. onAddCartClicked(){
  429. },
  430. //- 点击购买,跳转确认订单
  431. onBuyClicked(mallinfo) {
  432. console.log(mallinfo)
  433. if(this.sku.none_sku){
  434. mallinfo.selectedSkuComb.price = mallinfo.selectedSkuComb.price / 100;
  435. mallinfo.selectedSkuComb.id = '';
  436. }else{
  437. mallinfo.selectedNum = this.nowSelectedNum;
  438. };
  439. //- 清除仓库Id
  440. PublicLib.putCookieInfo('warehouseId', '');
  441. //- 清除收货地址Id
  442. PublicLib.putCookieInfo('addressId', '');
  443. PublicLib.putCookieInfo('checkmallInfo', JSON.stringify(mallinfo));
  444. if(this.mallid === '10' || this.mallid === '11' || this.mallid === '27' || this.mallid === '28' || this.mallid === '29' || this.mallid === '12' || this.mallid === '13' || this.mallid === '15' || this.mallid === '16' || this.mallid === '26'){
  445. PublicLib.Goto({Url:'mall-deal-check-coupon'});
  446. }else if(this.mallid === '8' || this.mallid === '9' || this.mallid === '7'){
  447. PublicLib.Goto({Url:'mall-deal-check'});
  448. }else{
  449. PublicLib.Goto({Url:'mall-deal-check-other'});
  450. };
  451. },
  452. goback(){
  453. PublicLib.GoBack({Level:1});
  454. }
  455. }
  456. });
  457. </script>
  458. </body>
  459. </html>