Browse Source

添加立即购买功能

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

14
api/goods.js

@ -14,6 +14,7 @@ const api = {
createOrder: "AgencyAddress/order/createOrder",
paymentListUrl: "Paymentlist/certiaudit/listIndet",
certificationPay: "PayCallBack/order/certificationPay",
rankingList: "AgencyAddress/ranking/queryList",
}
// 商品列表
@ -80,4 +81,15 @@ export const paymentList = (data) => {
// 缴费订单列表
export const 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%;
display: flex;
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;
justify-content: space-evenly;
margin-right: 12rpx;
flex-basis: 33%;
.fast-item {
position: relative;
@ -279,6 +304,7 @@
// 操作按钮
.foo-item-btn {
flex: 1;
flex-basis: 33%;
.btn-wrapper {
height: 100%;

222
pages/goods/detail.vue

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

Loading…
Cancel
Save