1、detail页面 /items/detail/:id
- <template>
- <div class="item_detail">
- <van-swipe :autoplay="3000" indicator-color="white">
- <van-swipe-item v-for="(item,index) in goods.pictureList" v-bind:key="index"><img :src="item.url"></van-swipe-item>
- </van-swipe>
- <div class="buy-area">
- <h2 class="title">
- <!-- OGAWA 奥佳华 舒行者全自动按摩椅 OG-7105 泰式定 位拉抻按摩椅 -->
- {{goods.title}}
- </h2>
- <p class="des">
- <!-- 透彻拉筋放松,舒畅全身;如儿时摇篮般的舒适体验;压肩揉按,抚慰颈部疲劳 -->
- {{goods.desc}}
- </p>
- <div class="point">
- {{goods.minScorePrice}} 积分
- </div>
- </div>
- <div class="detail-title">
- <span>
- 商品详情
- </span>
- </div>
- <div class="content" v-html="goods.detail">
- </div>
- <van-goods-action>
- <van-goods-action-big-btn primary @click="doBuyNow" text="立即兑换" />
- </van-goods-action>
- <div v-show="showBase">
- <div class="alertBox">
- <div class="mainbox">
- <i class="van-icon van-icon-close icon-pos" @click="doClose"></i>
- <div v-for="(item,n) in itemList" v-bind:key="n">
- <div class="stand-title">
- {{item.specNameTitle}}
- </div>
- <div class="stand-cont clearfix">
- <div class="item" v-for="(oItem,index) in item.valueList" :class="[oItem.notShowFlag == 1 ? 'disabled' : '',subIndex[n] == index ? 'active': '']" @click="select(n,index,item.specNameId,oItem.specNameValueId,oItem.notShowFlag)" v-bind:key="index">{{oItem.specNameValueTitle}}</div>
- <!-- <div class="item active">红</div>https://blog.csdn.net/yx_cos/article/details/82499389
- <div class="item">黑</div>https://blog.csdn.net/panyang01/article/details/76665448 https://blog.csdn.net/this_ITBoy/article/details/82724701
- <div class="item disabled">白</div> -->
- </div>
- </div>
- <div class="count clearfix">
- <span>
- 数量选择
- </span>
- <van-stepper v-model="value" :max="maxAmount" />
- </div>
- </div>
- <div class="btmBtn" @click="doPay()">
- 确认兑换
- </div>
- </div>
- </div>
- <div class="van-modal" v-show="showBase" @click="doClose" style="z-index: 10;"></div>
- </div>
- </template>
- <script>
- // import { GOODS_DETAIL } from '@/api/goods';
- import {
- Swipe,
- SwipeItem,
- GoodsAction,
- GoodsActionBigBtn,
- GoodsActionMiniBtn,
- Popup,
- Sku,
- Stepper,
- Toast
- } from 'vant';
- export default {
- props: {
- itemId: [String, Number]
- },
- data() {return {
- value: 1,
- showBase: false,
- goods: {},
- subIndex: [],
- accessFlag: true,
- itemList: [],
- tmpItemList: [],
- skuList: [],
- tmpStr: "",
- specStr1: "",
- specStr2: "",
- skuId: "",
- maxAmount: 1
- };
- },
- computed: {
- },
- created() {
- // var that = this
- // history.pushState(null, null, document.URL);
- // window.addEventListener('popstate', function(e) {
- // that.$router.replace({path: '/'})
- // // history.pushState(null, null, location.protocol+'//'+location.host + '/');
- // });
- window.scrollTo(0,0)
- this.initData();
- },
- destroyed(){
- this.doClose()
- },
- beforeRouteLeave(to, from, next){
- this.doClose()
- next();
- },
- methods: {
- initData() {
- // this.$reqGet(`${GOODS_DETAIL}`, {
- // expand: 'desc,skus,prop_imgs,item_imgs'
- // }).then(res => {
- // this.goods = res.data.data;
- // });
- var that = this
- this.$reqGet('/product/get-product?productId='+that.itemId).then(function(res) {
- console.log(res)
- that.goods = res.data.body.productWithList
- that.itemList = res.data.body.specValueVOList
- that.skuList = res.data.body.skuList
- that.tmpItemList = res.data.body.specValueVOList
- }).catch(function(err) {
- console.log(err)
- })
- },
- doBuyNow() {
- this.value = 1
- this.showBase = true
- document.body.style.height = '100vh'
- document.body.style['overflow'] = 'hidden'
- document.body.style.position = 'fixed'
- this.itemList = JSON.parse(JSON.stringify(this.tmpItemList)) // 隐藏后初始化弹出选中 与 disabled
- this.subIndex = [] // 隐藏后初始化弹出选中 与 disabled
- },
- doClose() {
- this.value = 1
- this.showBase = false
- document.body.style.height = 'unset'
- document.body.style['overflow'] = 'auto'
- document.body.style.position = ''
- this.itemList = this.tmpItemList
- },
- doPay() {
- var that = this
- if (this.subIndex.length == 0) {
- this.$toast('请选择规格');
- return false;
- }
- if(this.subIndex.length < this.goods.nameList.length) {
- this.$toast('请选择规格');
- return false;
- }
- if (that.subIndex.indexOf(-1) > -1) {
- this.$toast('请选择规格');
- return false
- }
- // this.tmpStr = this.specStr1 + this.specStr2
- // console.log(this.tmpStr,2)
- // return false;
- // this.skuList.forEach(function (item,index) {
- // if (that.tmpStr == item.specStr) {
- // that.skuId = item.skuId
- // that.maxAmount = item.stock
- // if(that.value > that.maxAmount) {
- // that.value = that.maxAmount
- // return false
- // }
- // }
- // })
- if (this.accessFlag) {
- this.$reqPost('/order/add-order',{remark:"",products:[{skuId:that.skuId,quantity:that.value}]}).then(function(res) {
- console.log(res)
- if(res.data.body.status) {
- // that.doClose()
- that.$router.push({path:'/items/write',query:{skuId:that.skuId,orderNo:res.data.body.data}})
- }else{
- that.$toast(res.data.body.msg);
- that.initData()
- }
- }).catch(function(err) {
- console.log(err)
- })
- }
- },
- select(n,index,pid,cid,flag) {
- if (flag == 1) {
- return false;
- }
- if (n == 0) {
- this.specStr1 = 'nameId'+pid+','+'valueId'+cid+',';
- }
- if (n == 1) {
- this.specStr2 = 'nameId'+pid+','+'valueId'+cid+',';
- }
- // console.log(this.specStr1,this.specStr2)
- if(this.subIndex[n] == index) {
- this.subIndex[n] = -1 //去掉选中状态 下面去掉当时选中德str 同时赋值
- if (n == 0) {
- this.specStr1 = "";
- }
- if (n == 1) {
- this.specStr2 = "";
- }
- this.$set(this.subIndex, n, -1)
- }else {
- this.subIndex[n] = index
- this.$set(this.subIndex, n, index)
- }
- // 判断规格为两种搭配情况下的stock为0情况下 是否不可点击按钮(disabled) (规格为一种时候 通过后台返回的notShowFlag 判断 规格为两种时候 第二种的notShowFlag 为1)
- var that = this
- if (this.itemList.length == 2 && n == 0) {
- this.itemList[1].valueList.forEach(function(item,index) {
- var ppStr1 = that.specStr1 + 'nameId'+that.itemList[1].specNameId+','+'valueId'+item.specNameValueId+','
- that.skuList.forEach(function(obj,j) {
- // console.log(ppStr1,obj.specStr,obj.stock)
- if (ppStr1 == obj.specStr) {
- if(obj.stock == 0) {
- item.notShowFlag = 1
- }else{
- item.notShowFlag = 0
- }
- }
- })
- })
- }
- if (this.itemList.length == 2 && n == 1) {
- this.itemList[0].valueList.forEach(function(item,index) {
- var ppStr2 ='nameId'+that.itemList[0].specNameId+','+'valueId'+item.specNameValueId+','+that.specStr2
- that.skuList.forEach(function(obj,j) {
- // console.log(ppStr2,obj.specStr,obj.stock)
- if (ppStr2 == obj.specStr) {
- if(obj.stock == 0) {
- item.notShowFlag = 1
- }else{
- item.notShowFlag = 0
- }
- }
- })
- })
- }
- this.tmpStr = this.specStr1 + this.specStr2
- // console.log(this.tmpStr,1)
- this.skuList.forEach(function (item,index) {
- if (that.tmpStr == item.specStr) {
- that.skuId = item.skuId
- that.maxAmount = item.stock
- if(that.value > that.maxAmount) {
- that.value = that.maxAmount
- return false
- }
- }
- })
- // console.log(this.maxAmount,2)
- // this.subIndex[n] = index
- // this.$set(this.subIndex, n, index)
- // console.log(n,index,pid,cid)
- }
- },
- components: {
- [Popup.name]: Popup,
- [Swipe.name]: Swipe,
- [SwipeItem.name]: SwipeItem,
- [GoodsAction.name]: GoodsAction,
- [GoodsActionBigBtn.name]: GoodsActionBigBtn,
- [GoodsActionMiniBtn.name]: GoodsActionMiniBtn,
- [Sku.name]: Sku,
- [Stepper.name]: Stepper,
- [Toast.name]: Toast
- }
- };
- </script>
- <style lang="scss" scoped>
- .clearfix::after{
- display: block;
- content: '';
- clear: both;
- height: 0;
- }
- .van-swipe{
- height: 11.25rem !important;
- background: #fff;
- }
- .van-icon-close:before {
- content: "\F015" !important;
- }
- .van-modal {
- position: fixed;
- width: 100%;
- height: 100%;
- top: 0;
- left: 0;
- background-color: rgba(0,0,0,.7);
- }
- .buy-area {
- padding: 0.36rem;
- line-height: 1.9;
- background: #fff;
- .title {
- font-size: 0.42rem;
- margin: 0px;
- }
- .des {
- margin: 0px;
- padding-top: 0.45rem;
- font-size: 0.36rem;
- color: #999;
- }
- .point {
- padding-top: 1rem;
- color: #ff8400;
- font-size: 0.54rem;
- }
- }
- .item_detail {
- img {
- max-width: 100%;
- }
- }
- .detail-title{
- height: 1.6rem;
- line-height: 1.6rem;
- padding: 0 0.36rem;
- background: #fff;
- font-size: 0.42rem;
- font-weight: bold;
- margin-top: 0.3rem;
- span {
- padding-left: 0.25rem;
- display: block;
- position: relative;
- }
- span::before{
- display: block;
- content: '';
- position: absolute;
- left: 0;
- height: 0.4rem;
- width: 2px;
- top: 0.6rem;
- background: #fd141d;
- }
- }
- .content {
- background: #fff;
- min-height: 11.25rem;
- /deep/ img {
- width: 100%;
- margin: 0px;
- padding: 0px;
- vertical-align: middle;
- }
- /deep/ p {
- margin: 0px;
- padding: 0px;
- }
- }
- .van-button--danger{
- background: #fd141d;
- }
- .alertBox {
- height: auto;
- position: fixed;
- bottom: 0;
- z-index: 11;
- background: #fff;
- left: 0;
- right: 0;
- font-size: 0.42rem;
- }
- .alertBox .mainbox {
- max-height: 260px;
- overflow-y: scroll;
- -webkit-overflow-scrolling: touch;
- }
- .alertBox .btmBtn {
- height: 50px;
- line-height: 50px;
- text-align: center;
- color: #fff;
- background: #fd141d;
- font-size: 16px;
- }
- .alertBox .stand-title {
- height: 1.6rem;
- line-height: 1.6rem;
- padding: 0 0.36rem;
- border-bottom: 1px #f6f6f9 solid;
- }
- .alertBox .icon-pos {
- position: absolute;
- right: 0.36rem;
- top: 0.6rem;
- }
- .alertBox .stand-cont {
- padding: 0.56rem 0.36rem;
- }
- .alertBox .stand-cont .item {
- float: left;
- min-width: 2.4rem;
- height: 0.9rem;
- border-radius: 0.45rem;
- padding: 0 0.45rem;
- border: 1px solid #f6f6f9;
- background: #f6f6f9;
- text-align: center;
- line-height: 0.9rem;
- margin-right: 0.6rem;
- margin-bottom: 0.3rem;
- }
- .alertBox .stand-cont .item.active {
- background: #fff8f8;
- border-color: #fd141d;
- color: #fd141d;
- }
- .alertBox .stand-cont .item.disabled {
- background: #f6f6f9;
- border-color: #f6f6f9;
- color: #b4b4b9;
- }
- .alertBox .count {
- padding: 0.6rem 0.36rem;
- }
- .alertBox span {
- display: block;
- float: left;
- height: 30px;
- line-height: 30px;
- }
- .van-stepper {
- float: right;
- }
- .van-button {
- height: 50px;
- line-height: 50px;
- }
- </style>
1、detail页面 /items/detail/:id的更多相关文章
- 获得同级iframe页面的指定ID元素的几种实现方法
1.JS实现: var object= window.parent.frames("要获得的iframe的name").contentDocument.getElementById ...
- js中对arry数组的各种操作小结 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据 web前端url传递值 js加密解密 HTML中让表单input等文本框为只读不可编辑的方法 js监听用户的键盘敲击事件,兼容各大主流浏览器 HTML特殊字符
js中对arry数组的各种操作小结 最近工作比较轻松,于是就花时间从头到尾的对js进行了详细的学习和复习,在看书的过程中,发现自己平时在做项目的过程中有很多地方想得不过全面,写的不够合理,所以说啊 ...
- 2、订单填写页面 /items/write?skuId=10&orderNo=201903211033410001
<template> <div class="write"> <div class="adr" v-if="addres ...
- 关于页面里没有id属性的Javascript上的解决办法
如果页面上只有Textarea,可以用如下方法来遍历其name属性然后赋给id属性:<script> try{ window.onload = setTextAreaIds();setTe ...
- 单页面网站关于id冲突的解决办法
最近做了一个单页面的网站,所有的页面加载都是通过局部刷新的方式,并且不用iframe,并且我们引入了动态tab页签: 所有的页签里的内容都只是一个元素,都在同一个html页面上,没有任何iframe分 ...
- 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据
瀑布流加载显示数据,在当下已经用的很普遍,尤其是我们在做网上商城时,在产品列表页面已经被普遍使用. 对于实现瀑布流布局的解决方案主要有以下两种方式: 1.对每一条显示数据使用绝对定位+浮动的方式,这样 ...
- aspx页面控件id上自动加前缀
公司的一个.net项目,使用的传统aspx页面开发,每个控件上自动加了前缀,最初以为是extjs.net自带的功能,后来研究发现,主要是因为内部使用了母版页.<asp:Content ID=&q ...
- jquery 在页面上根据ID定位(jQuery锚点跳转及相关操作) 经典
1.锚点跳转简介 Edit 锚点其实就是可以让页面定位到某个位置上的点.在高度较高的页面中经常见到.比如百度的百科页面,wiki中的page内容. 我知道实现锚点的跳转有两种形式,一种是a标签+nam ...
- 一个页面有相同ID元素的情况分析
经常会遇到一个页面中有相同定义相同id的情况,从道理上来说,id应该是这个页面中某个元素的唯一标识,所以不应该出现有相同id的情况,否则会产生意想不到的结果.而且各个浏览器的表现也是不一样的.我只做了 ...
随机推荐
- datePecker时间控件区间写法
成交时间: <input type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$d ...
- spring(二、bean生命周期、用到的设计模式、常用注解)
spring(二.bean生命周期.用到的设计模式.常用注解) Spring作为当前Java最流行.最强大的轻量级框架,受到了程序员的热烈欢迎.准确的了解Spring Bean的生命周期是非常必要的. ...
- 读书笔记--《gongchandang宣言》
纪念马克思诞辰200周年 末尾 gongchandang人不屑于隐瞒自己的观点和意图.他们公开宣布:他们的目的只有用暴力推翻全部现存的社会制度才能达到. 让统治接机在共产主义革命面前发抖吧. 无产者在 ...
- nodeJS网络操作
var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, ...
- requests.get() 的 headers 参数
官方文档requests.get()方法的定义如下: 源码如下: 看到最后一行return,get方法最后是通过调用requests.request 方法实现的,其实在其它的请求方法如post,put ...
- 使用Blend设计出符合效果的WPF界面
之前不会用blend,感觉好难的,但美工给出的效果自己有没办法实现,所以研究了一下blend,感觉没有想象中的那么难 废话不多说,开始界面设计 今天拿到美工给的一个界面效果图 这个界面说实话,还可以吧 ...
- Java_EE面试题
Java_EE面试题 欢迎到我的Git仓库去提交您觉得优秀的内容! 1.什么是Servlet? Servlet是用来处理客户端请求并产生动态网页内容的Java类.Servlet主要是用来处理或者是存储 ...
- 一个基于typelist的typemap
前面的typelist的e一个小扩展,http://www.cnblogs.com/flytrace/p/3551414.html. 可以插入pair<key_type, value_type& ...
- nginx的启动,停止和重启
启动 启动代码格式:nginx安装目录地址 -c nginx配置文件地址 例如: [root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /us ...
- 关于性能(SEO)
性能优化有很多方面:细节决定成败,系统慢是由一个又一个的小细节造成的,所以开发初期做好充足的准备,开发中认真负责,不偷工减料,维护期更注重代码质量,这样才会让我妈的系统稳定高效. 1.0 使用CDN( ...