Browse Source

添加立即购买功能

master
wanghongjun 2 years ago
parent
commit
537719daa0
  1. 12
      api/goods.js
  2. 26
      pages/goods/detail.scss
  3. 218
      pages/goods/detail.vue

12
api/goods.js

@ -14,6 +14,7 @@ const api = {
createOrder: "AgencyAddress/order/createOrder", createOrder: "AgencyAddress/order/createOrder",
paymentListUrl: "Paymentlist/certiaudit/listIndet", paymentListUrl: "Paymentlist/certiaudit/listIndet",
certificationPay: "PayCallBack/order/certificationPay", certificationPay: "PayCallBack/order/certificationPay",
rankingList: "AgencyAddress/ranking/queryList",
} }
// 商品列表 // 商品列表
@ -81,3 +82,14 @@ export const paymentList = (data) => {
export const certificationPay = (paramStr) => { export const certificationPay = (paramStr) => {
return request.post(api.certificationPay + paramStr,{}) return request.post(api.certificationPay + paramStr,{})
} }
// 标的推荐
export const getRankingList = (param) => {
let paramArr = [];
for (let key in param) {
paramArr.push(key + '=' + param[key])
}
let paramStr = '?' + paramArr.join('&')
return request.get(api.rankingList + paramStr,{})
}

26
pages/goods/detail.scss

@ -217,6 +217,30 @@
width: 100%; width: 100%;
display: flex; display: flex;
height: 106rpx; height: 106rpx;
flex-wrap: wrap;
}
.foo-item-price {
flex-basis: 100%;
view {
display: inline-block;
}
.btn-item-year {
margin-top: 15rpx;
}
.btn-item-input {
float: right;
display: inline-block;
margin-top: 10rpx;
width: 300rpx;
}
.btn-item-addprice {
float: right;
margin-top: 15rpx;
}
} }
// 快捷菜单 // 快捷菜单
@ -228,6 +252,7 @@
align-items: center; align-items: center;
justify-content: space-evenly; justify-content: space-evenly;
margin-right: 12rpx; margin-right: 12rpx;
flex-basis: 33%;
.fast-item { .fast-item {
position: relative; position: relative;
@ -279,6 +304,7 @@
// 操作按钮 // 操作按钮
.foo-item-btn { .foo-item-btn {
flex: 1; flex: 1;
flex-basis: 33%;
.btn-wrapper { .btn-wrapper {
height: 100%; height: 100%;

218
pages/goods/detail.vue

@ -155,6 +155,17 @@
<!-- 底部选项卡 --> <!-- 底部选项卡 -->
<view class="footer-fixed"> <view class="footer-fixed">
<view class="footer-container"> <view class="footer-container">
<view class="foo-item-price">
<view v-if="shopyear_show" class="">
<view class="btn-item-year">请输入年限</view>
<input class="uni-input btn-item-input" v-model="use_years" maxlength="10" placeholder="请输入年限" v-on:input="ipt()"/>
</view>
<view v-if="talprice_show" class="btn-item-addprice" @click="addCart()">
<text>合计{{addprice}}</text>
</view>
</view>
<view class="foo-item-fast"> <view class="foo-item-fast">
<!-- 进入店铺 --> <!-- 进入店铺 -->
<view class="btn-item btn-item-main" @click="goteshop()"> <view class="btn-item btn-item-main" @click="goteshop()">
@ -169,7 +180,7 @@
<view v-if="shopcart_show" class="btn-item btn-item-deputy" @click="addCart()"> <view v-if="shopcart_show" class="btn-item btn-item-deputy" @click="addCart()">
<text>{{shopcart_str}}</text> <text>{{shopcart_str}}</text>
</view> </view>
<view v-if="purchase_show" class="btn-item btn-item-main" @click="buyNow()"> <view class="btn-item btn-item-main" @click="buyNow()">
<text>立即购买</text> <text>立即购买</text>
</view> </view>
@ -242,7 +253,8 @@
shopyear_num: '', // shopyear_num: '', //
shopcart_str: '加入购物车', shopcart_str: '加入购物车',
new_total: 0, // new_total: 0, //
addprice: 0, //
use_years: '', //
} }
}, },
@ -282,6 +294,7 @@
app.new_total = res.data.total app.new_total = res.data.total
let imgitem = {"imgurl":app.goods.goods_images} let imgitem = {"imgurl":app.goods.goods_images}
app.gdimgs.push(imgitem) app.gdimgs.push(imgitem)
app.transfer(app.goods.goods_entrust, app.goods.price); //
// //
if(app.goods.username == "中国数字文化集团有限公司" || if(app.goods.username == "中国数字文化集团有限公司" ||
app.goods.username == "国家图书馆出版社有限公司" || app.goods.username == "国家图书馆出版社有限公司" ||
@ -300,6 +313,9 @@
app.shopyear_show = true app.shopyear_show = true
app.talprice_show = true app.talprice_show = true
app.purchase_show = true app.purchase_show = true
let footer = document.querySelector('.footer-container');
//
footer.style.height = '100px'; // 200px
} else { } else {
app.ears_of = 3 app.ears_of = 3
app.shopcart_show = true app.shopcart_show = true
@ -312,7 +328,6 @@
item.source_data.metadataFileSize = app.FileSize(item.source_data.metadataFileSize) item.source_data.metadataFileSize = app.FileSize(item.source_data.metadataFileSize)
item.source_data.releaseTime = item.source_data.releaseTime.split(" ")[0] item.source_data.releaseTime = item.source_data.releaseTime.split(" ")[0]
}) })
console.log(app.goods.source)
resolve(res) resolve(res)
}).catch(reject); }).catch(reject);
}) })
@ -325,80 +340,153 @@
var sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], var sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
i = Math.floor(Math.log(data) / Math.log(k)); i = Math.floor(Math.log(data) / Math.log(k));
return (data / Math.pow(k, i)).toPrecision(3) + " " + sizes[i]; return (data / Math.pow(k, i)).toPrecision(3) + " " + sizes[i];
}, },
ipt(){
// if (this.use_years) {
goteshop(){ let shopRice = Math.round(parseFloat(this.goods.price * 100 * this.use_years)) / 100;
const app = this this.addprice = shopRice
let spname = this.goods.username } else {
this.$navTo("pages/goods/list?k="+spname+'&dt='+new Date().getTime()) this.addprice = 0
}, }
},
//
goteshop(){
const app = this
let spname = this.goods.username
this.$navTo("pages/goods/goodsDetail?k="+spname+'&dt='+new Date().getTime())
},
//
transfer(pass_Num,pricets) {
if (pass_Num == "1") {
this.shopyear_show = false
this.addprice = pricets
this.use_years = 99
}
},
//
addCart(){
const app = this
let accessToken = uni.getStorageSync("AccessToken")
if (accessToken) {
let isliCode = uni.getStorageSync("isliCode")
if (isliCode) {
let userType = uni.getStorageSync("userType")
if (userType == '0') {
app.$toast('个人认证账号不能加入购物车')
} else {
if (app.ears_of === 2) {
// let shopyear_num = app.shopyear_num
addCart(){ if (shopyear_num === 0 || shopyear_num === '') {
const app = this app.$error('购买年限只能输入整数')
let accessToken = uni.getStorageSync("AccessToken") } else {
if (accessToken) { app.shop_goods()
let isliCode = uni.getStorageSync("isliCode") }
if (isliCode) { }
let userType = uni.getStorageSync("userType") if (app.ears_of === 3 || app.ears_of === 1) {
if (userType === '0') { app.shop_goods()
app.$toast('个人认证账号不能加入购物车') }
}
} else {
app.$toast('账号未认证,请进行认证!')
setTimeout(app.jumpMycertinfoUrl,3000)
}
} else {
app.$toast("请先登录")
setTimeout(app.jumpUrl('/pages/login/index'),3000)
}
},
jumpMycertinfoUrl (url) {
uni.navigateTo({
url:'/pages/user/mycertinfo/mycertinfo'
})
},
//
shop_goods() {
const app = this
let param = {
goods_isli : app.goods.goods_islicode,
user_isli : uni.getStorageSync("isliCode"),
use_years : 0,
}
if (app.ears_of === 3) {
param.use_years = 1
}
GoodsApi.addShoppingCa(param).then(res => {
if (res.resultCode === "00000000") {
app.$success("加入购物车成功");
app.shopcart_str = '已加入购物车'
} else { } else {
if (app.ears_of === 2) { app.$error(res.errMsg);
}
}).catch()
},
//
buyNow() {
const app = this
let accessToken = uni.getStorageSync("AccessToken")
if (accessToken) {
let isliCode = uni.getStorageSync("isliCode")
if (isliCode) {
let userType = uni.getStorageSync("userType")
if (userType == '0') {
app.$toast('个人认证账号不能加入购物车')
} else {
let type_status = app.goods.goods_status
let title_Name = app.goods.goods_name;
let ears_of = app.ears_of
let addprice = app.addprice
if (type_status == 0 || type_status == 5) {
if (ears_of == '2') {
if (addprice) {
app.Buy_now()
} else {
app.$toast('请输入购买年限')
}
}
if (ears_of == "1") {
app.Buy_now()
}
let shopyear_num = app.shopyear_num
if (shopyear_num === 0 || shopyear_num === '') {
app.$error('购买年限只能输入整数')
} else { } else {
app.shop_goods() if (type_status == 5) {
app.$toast(title_Name + '正在委托中,无法购买')
} else {
app.$toast(title_Name + '无法购买')
}
} }
} }
if (app.ears_of === 3 || app.ears_of === 1) { } else {
app.shop_goods() app.$toast('账号未认证,请进行认证!')
} setTimeout(app.jumpMycertinfoUrl,3000)
} }
} else { } else {
app.$toast('账号未认证,请进行认证!') app.$toast("请先登录")
setTimeout(app.jumpMycertinfoUrl,3000) setTimeout(app.jumpUrl('/pages/login/index'),3000)
} }
} else { },
app.$toast("请先登录") Buy_now() {
setTimeout(app.jumpUrl('/pages/login/index'),3000) const app = this
} let param = {
}, goods_isli : app.goods.goods_islicode,
jumpMycertinfoUrl (url) { user_isli : uni.getStorageSync("isliCode"),
uni.navigateTo({ is_car : 2, //12
url:'/pages/user/mycertinfo/mycertinfo' use_years : app.use_years ? app.use_years : 0,
})
},
//
shop_goods() {
const app = this
let param = {
goods_isli : app.goods.goods_islicode,
user_isli : uni.getStorageSync("isliCode"),
use_years : 0,
}
if (app.ears_of === 3) {
param.use_years = 1
}
GoodsApi.addShoppingCa(param).then(res => {
console.log(res)
if (res.resultCode === "00000000") {
app.$success("加入购物车成功");
app.shopcart_str = '已加入购物车'
} else {
app.$error(res.errMsg);
} }
}).catch() GoodsApi.createOrder(param).then(res => {
}, if (res.resultCode === "00000000") {
// //
buyNow(){
this.$toast("buy now")
},
this.$navTo('pages/goods/payment', { batchcode:res.data.batchcode, img: app.goods.img, time: new Date().getTime() })
} else {
app.$error(res.errMsg);
}
}).catch()
},
// //
onTargetHome(e) { onTargetHome(e) {
this.$navTo('pages/index/index') this.$navTo('pages/index/index')

Loading…
Cancel
Save