This commit is contained in:
2024-05-17 18:02:49 +08:00
parent 8407d51fb6
commit b5264dc222
4056 changed files with 308094 additions and 41932 deletions

View File

@@ -0,0 +1,400 @@
<template>
<view class="">
<view class="shopHeader">
<!-- 顶部导航栏 -->
<z-nav-bar title="健康超市"></z-nav-bar>
<!-- 搜索 -->
<!-- <view class="search" @click="goSearch()">
<u-search placeholder="请输入需4545要的商品" v-model="keyword" :show-action="false"></u-search>
</view> -->
</view>
<!-- 主盒子 -->
<view class="indexBox">
<!-- 轮播图 -->
<view class="swiper_box">
<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
<swiper-item v-for="(item,index) in swiperlist" :key="index">
<view class="swiper-item">
<image :src="item.image" mode="widthFix " class="swiperImg"></image>
</view>
</swiper-item>
</swiper>
</view>
<!-- 分类 -->
<view class="head_line">
<b></b>
<text>商品分类</text>
</view>
<view class="classfy">
<view v-for="(item,index) in gridArr" :key="index" @click='toClassify(item.catId,index)'>
<!-- <u-icon v-if="item.icon" :name="item.icon" :size="46"></u-icon> -->
<image :src="item.icon"></image>
<text class="grid-text">{{item.name}}</text>
</view>
<br clear="both">
</view>
<!-- 商品展示 -->
<view class="head_line">
<b></b>
<text>限时秒杀</text>
<i @click="onShopMore('Sale')">查看更多 ></i>
</view>
<!-- 限时秒杀 -->
<view class="limited">
<view class="limitedSymbol">
<image src="../../static/icon/shopping_xsh.png"></image>
</view>
<view class="limitedScrollBox">
<u-scroll-list indicatorActiveColor="#27b386">
<view class="limitedItem" v-for="(item,index) in seckillList" :key="index"
@click="goDetail(item.prodInfo.productId)">
<image :src="item.prodInfo.productImages" mode=""></image>
<text class="biaoti">{{item.prodInfo.productName}}</text>
<text class="xian">{{item.seckillPrice}}</text>
<text class="yuan">{{item.prodInfo.price}}</text>
</view>
</u-scroll-list>
</view>
</view>
<!-- 商品展示 -->
<view class="head_line">
<b></b>
<text>精选商品</text>
<i @click="onShopMore('Hot')">查看更多 ></i>
</view>
<view class="goods">
<view class="goodsItem" v-for="(item,index) in goodsList" :key="item.productId"
@click="goDetail(item.productId)">
<image :src="item.productImages" mode="" class="goodsImg"></image>
<view class="goodsContent">
<view class="goodsName">
{{item.productName}}
</view>
<view class="goodsPrice">
{{item.price}}
</view>
</view>
</view>
<br clear="both">
</view>
<view style="height: 30rpx;"></view>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<music-play :playData="playData"></music-play>
</view>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import {
mapState
} from 'vuex';
export default {
data() {
return {
playData:{},
keyword: '', // 搜索索引值
// 轮播图数据
swiperlist: [{
image: '../../static/icon/home_ban_1.jpg',
},
{
image: '../../static/icon//home_ban_2.jpg',
},
{
image: '../../static/icon//home_ban_3.jpg',
}
],
totalCount: 4,
pageSize: 1,
totalPage: 4,
currPage: 1,
limit: 4,
page: 1,
istop: 1, // 是否是精选商品
// 秒杀列表
seckillList: [],
// 商品列表
goodsList: [],
// 分类数据
gridArr: [{
icon: "list-dot",
name: '更多'
}],
}
},
computed: {
...mapState(['userInfo']),
},
components: {
musicPlay
},
onLoad() {
// 获取分类
this.$http
.post('book/shopcategory/getOneLevel')
.then(res => {
// 用一个空数组去接分类数据
let arr = []
if (res.list.length >= 5) {
for (let i in res.list) {
if (i < 5) {
arr.push({
icon: "../../static/icon/shop_bar_" + (Number(i) + Number(1)) + ".png",
name: res.list[i].name,
catId: res.list[i].catId
})
}
}
arr.push({
icon: "../../static/icon/shop_bar_more.png",
name: '更多'
})
this.gridArr = arr
}
})
// 获取限时秒杀
this.$http
.get(`book/shopseckill/getSeckillProd`)
.then(res => {
this.seckillList = res.list
console.log(this.seckillList)
})
// 获取精选商品
this.$http
.post(`book/shopproduct/appGetList?limit=${this.limit}&page=${this.page}&istop=${this.istop}`)
.then(
res => {
this.goodsList = res.page.list
})
},
methods: {
// 跳转详情页
goDetail(id) {
uni.navigateTo({
url: './commodityDetail?id=' + id
});
},
// 跳转分类页
toClassify(catId, index) {
if (catId) {
uni.navigateTo({
url: `./classify?type=${index}`
})
} else {
uni.navigateTo({
url: './classifyAll'
})
}
},
// 跳转搜索页
goSearch() {
uni.navigateTo({
url: './commoditySearch'
})
},
// 列表跳页
onShopMore(e) {
uni.navigateTo({
url: './bookShopType?type=' + e
});
},
}
}
</script>
<style lang="scss" scoped>
.shopHeader {
position: relative;
top: 0;
left: 0;
}
.search {
padding: 10rpx;
background-color: #fff;
margin: 10rpx 0;
}
.swiper_box {
margin-top: 20rpx;
padding: 0 20rpx;
.swiper-item {
width: 100%;
height: 100%;
border-radius: 20rpx;
.swiperImg {
width: 100%;
height: 100%;
border-radius: 20rpx;
}
}
}
.classfy {
margin: 0 10rpx;
border-radius: 30rpx;
view {
float: left;
width: 16.6%;
text-align: center;
image {
width: 100rpx;
height: 100rpx;
margin: 0 auto;
}
.grid-text {
font-size: 25rpx;
margin-top: 4rpx;
}
}
}
.head_line {
margin: 30rpx 0 30rpx 0;
padding: 10rpx;
b {
display: inline-block;
width: 12rpx;
height: 40rpx;
background-color: #54a966;
vertical-align: bottom;
margin: 0 20rpx 0 0;
}
text {
font-size: 32rpx;
font-weight: bold;
}
i {
float: right;
font-style: normal;
color: #8b8a91;
font-size: 24rpx;
margin: 15rpx 35rpx 0 0;
}
}
.limited {
width: 100%;
height: auto;
padding: 20rpx 10rpx 10rpx 10rpx;
display: flex;
align-items: center;
background-color: #fff;
margin-top: 10rpx;
.limitedSymbol {
width: 22%;
height: 300rpx;
border-right: 1px solid #eee;
vertical-align: middle;
image {
width: 120rpx;
height: 120rpx;
margin: 45px auto 0 auto;
}
}
.limitedScrollBox {
width: 76%;
padding: 0 10rpx;
}
.limitedItem {
width: 200rpx;
text-align: center;
image {
width: 150upx;
height: 200upx;
margin: 15rpx auto 20rpx auto;
}
text {
font-size: 20rpx;
display: block;
}
.biaoti {
font-size: 30rpx;
margin: 10rpx 0 10rpx 0;
font-weight: bold;
}
.xian {
font-size: 32rpx;
color: #bf0c0c;
font-weight: bold;
}
.yuan {
text-decoration: line-through;
color: #c1c1c1;
}
}
}
.goods {
width: 100%;
.goodsItem {
display: inline-block;
width: 46%;
border-radius: 20rpx;
padding: 25rpx 25rpx 20rpx 25rpx;
margin: 0 20rpx 20rpx 20rpx;
background-color: #fff;
border: 1px solid #eee;
.goodsImg {
width: 98%;
height: 380rpx;
border-radius: 10rpx;
}
.goodsContent {
.goodsName {
margin-top: 10rpx;
font-size: 30rpx;
font-weight: bold;
}
.goodsPrice {
font-size: 30rpx;
margin: 5rpx 0 0 3rpx;
color: #bf0c0c;
font-weight: bold;
}
}
}
.goodsItem:nth-child(2n) {
margin-left: 0;
}
}
</style>

View File

@@ -0,0 +1,330 @@
<template>
<view>
<z-nav-bar :title="title"></z-nav-bar>
<view class="shop_list">
<view class="sl_tioa" v-for="(item,index) in shopList" @click="onShopJump(item)">
<image :src="item.productImages"></image>
<view class="sl_cont">
<view class="sl_tit">
<text class="bok_name">
{{item.productName}}
<span v-if="item.productStock==0" style="color: #aaa;font-size:26rpx;">无货</span>
</text>
</view>
<view class="sl_ric">
{{item.price}}
</view>
<view class="sl_del" v-if="shopScreen.type == 'Sale'">
{{item.oldprice}}
</view>
<view class="sl_gou" v-if="item.productStock>0" @click.stop="addShopCar(item)">
<u-icon name="shopping-cart" :size="26" color="#eba00b"></u-icon>
</view>
</view>
<br clear="both">
</view>
<view style="height: 1px;"></view>
</view>
<view>
<view v-if="status==0" style="text-align: center;">
<u-loading-icon style="display: inline-block;"></u-loading-icon>
<font style='vertical-align: super;margin-left: 10px;font-size: 26rpx;color: #909399;'>努力加载中</font>
</view>
<view v-if="status==1">
<u-divider text="全部加载完成"></u-divider>
</view>
</view>
<view style="padding-bottom: 20rpx;">
<u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle' :iconStyle="iconStyle"></u-back-top>
</view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
import {
mapState
} from 'vuex';
export default {
data() {
return {
playData:{},
scrollTop: 0,
status: 3,
shopScreen: {
type: '',
page: 1, //当前页码数
limit: 5, //单页数据数量
},
productInfo: {},
totalPage: 0,
totalCount: 0,
shopList: [],
bgiStyle: {
background: '#2ab58833'
},
iconStyle: {
fontSize: '40rpx',
fontWeight: 'bold',
color: '#54a966',
},
urList: '',
title: '',
}
},
// 返回顶部
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
// 下拉刷新
onReachBottom() {
this.status = 0
if (this.shopScreen.page < this.totalPage) {
this.shopScreen.page = this.shopScreen.page + 1
setTimeout(() => {
if (this.shopScreen.type == 'Hot') {
this.$http
.post(this.urList + '?page=' + this.shopScreen.page + '&limit=' + this.shopScreen
.limit)
.then(res => {
this.totalPage = res.page.totalPage
this.totalCount = res.page.totalCount
for (let i in res.page.list) {
this.shopList.push(res.page.list[i])
}
});
}
}, 1000)
} else {
this.status = 1
}
},
//第一次加载
onLoad(e) {
this.shopScreen.type = e.type
if (this.shopScreen.type == 'Sale') {
this.urList = 'book/shopseckill/getSeckillProd'
this.title = '限时秒杀'
} else if (this.shopScreen.type == 'Hot') {
this.urList = 'book/shopproduct/appGetList'
this.title = '精选商品'
}
this.getData();
},
//页面显示
onShow() {
// this.getData();
},
// 下拉刷新
onPullDownRefresh() {
this.getData()
uni.stopPullDownRefresh()
},
computed: {
...mapState(['userInfo']),
},
components: {
musicPlay
},
//方法
methods: {
// 获取列表数据
getData() {
console.log(this.urList)
this.shopList = []
if (this.shopScreen.type == 'Hot') {
this.$http
.post(this.urList + '?page=' + this.shopScreen.page + '&limit=' + this.shopScreen.limit)
.then(res => {
this.shopList = res.page.list
this.totalPage = res.page.totalPage
this.status = 3
});
} else if (this.shopScreen.type == 'Sale') {
this.$http
.get(this.urList)
.then(res => {
let arr = []
for (let i in res.list) {
arr.push({
productImages: res.list[i].prodInfo.productImages,
productName: res.list[i].prodInfo.productName,
price: res.list[i].seckillPrice,
oldprice: res.list[i].prodInfo.price,
productId: res.list[i].prodInfo.productId,
})
}
this.shopList = arr
this.status = 3
});
}
},
// 加入购物车
addShopCar(e) {
this.$http
.post(`book/ordercart/getCartList?userId=${this.userInfo.id}`)
.then(res => {
this.cartList = res.cartList
// 统计商品信息
let data = {
"userId": this.userInfo.id,
"productId": e.productId,
"productAmount": 1,
"price": e.price
}
console.log(e)
// 判断列表是否为空
if (this.cartList.length > 0) {
let flag = ''
let shagnpin = {}
// 循环购物车列表
flag = this.cartList.some((item, index) => {
if (item.productId == data.productId) {
shagnpin = item
shagnpin.productAmount = item.productAmount + 1
return true
}
})
if (flag) {
// 已在购物车中添加
$http.request({
url: "book/ordercart/update",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: shagnpin,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
} else {
// 加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
}
} else {
// 购物车列表为空时直接加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
}
})
},
// 商品内容跳转
onShopJump(e) {
uni.navigateTo({
url: './commodityDetail?id=' + e.productId
});
}
},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.shop_list {
margin: 30rpx;
.sl_tioa {
box-shadow: 0 0px 10px 1px #d3d1d133;
background-color: #fff;
padding: 25rpx;
margin: 0 0 20rpx 0;
border-radius: 15rpx;
position: relative;
image {
width: 160upx;
height: 240upx;
float: left;
margin-right: 20rpx;
}
.sl_cont {
float: left;
.sl_tit {
max-width: 420rpx;
font-size: 30rpx;
}
.sl_ric {
color: #bf0c0c;
font-weight: bold;
margin-top: 50rpx;
}
.sl_del {
text-decoration: line-through;
color: #c1c1c1;
font-size: 30rpx;
margin-left: 10rpx;
}
.sl_gou {
background-color: #fbf6ec;
border-radius: 50rpx;
padding: 5rpx;
position: absolute;
right: 50rpx;
bottom: 40rpx;
}
}
}
}
</style>

455
pages/bookShop/classify.vue Normal file
View File

@@ -0,0 +1,455 @@
<template>
<view class="">
<z-nav-bar title="健康超市"></z-nav-bar>
<!-- 一级分类 -->
<view class="oneBox">
<view class="oneLevel">
<u-tabs :scrollable="false" :current="current" lineWidth="42" :inactiveStyle="{fontSize:'32rpx'}"
:list="oneLevel" @click="getTowLevel" lineColor="#54a966"
:activeStyle="{color: '#303133',fontWeight: 'bold', transform: 'scale(1.01)'}"></u-tabs>
</view>
</view>
<!-- <view class="search_box" @click="onPageJump('../peanut/searchFor')">
<text class="icon_search"></text>
<text class="prompt">搜索...</text>
</view> -->
<!-- 二级分类商品 -->
<view class="twoBox" style="">
<!-- <u-sticky> -->
<u-tabs v-if="utabs" :list="towLevel" :current = "0" :inactiveStyle="{fontSize:'28rpx'}" lineWidth="40" @click="getCategoryList"
:activeStyle="{transform: 'scale(1.01)'}"></u-tabs>
<!-- </u-sticky> -->
</view>
<view class="classfyBody">
<!-- 二级分类商品 -->
<view class="towLevel" v-if="towLevel.length > 0">
<view class="towLevelContent" v-if="commodityList && commodityList.length > 0">
<view class="commodityItem" v-for="(item,index) in commodityList" :key="index"
@click.stop="toDetail(item.productId)">
<view class="box">
<image :src="item.productImages" mode=""></image>
<view class="commodityContent">
<view class="commodityTitle">
{{item.productName}}
<span v-if="item.productStock==0" style="color: #aaa;font-size:26rpx;">暂无库存</span>
</view>
<view class="commodityPrice">
<text class="price" v-if="item.price">
<b style="font-size: 40rpx;">{{item.price}}</b>
<span class="priceTag" v-if="item.activityPrice">原价{{item.activityPrice}}</span>
</text>
<text class="SoldNumber" v-if="item.sumSales">已售<span>{{item.sumSales}}</span></text>
<!-- <text class="icon" @click.stop="addShopCar(item)" v-if="item.productStock">
<u-icon name="shopping-cart" :size="26" color="#eba00b"></u-icon>
</text> -->
<view class="publierInfo" v-if="item.author && item.publisher">
<span class="c999 f24">{{item.author}}</span><span class="c999 f24">/ {{item.publisher}}</span>
</view>
</view>
</view>
</view>
</view>
</view>
<view v-else style="text-align: center;font-size: 30rpx;color: #888;margin: 20rpx 0 0 0;flex: 1;">
暂无商品
</view>
</view>
<view v-else style="text-align: center;font-size:30rpx;color: #888;margin: 50rpx 0 0 0;">
暂无分类
</view>
</view>
<view>
<u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle' :iconStyle="iconStyle"></u-back-top>
</view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
import {
mapState
} from 'vuex';
export default {
data() {
return {
playData:{},
highlight: '', // 高亮下标
current: 0,
twocurrent:0,
oneLevel: [],
towLevel: [],
commodityList: [] ,// 商品列表
utabs:false,
bgiStyle: {
background: '#2ab58833'
},
iconStyle: {
fontSize: '40rpx',
fontWeight: 'bold',
color: '#54a966',
},
scrollTop: 0,
}
},
// contentButtonClick(e) {
// console.log(e)
// },
// onLoad(e) {
// //获取一级分类
// this.$http
// .post('book/shopcategory/getOneLevel')
// .then(res => {
// this.oneLevel = res.list
// this.current = e.type
// this.getTowLevel(this.oneLevel[e.type])
// })
// },
//页面显示
onShow() {
this.getOneLevel()
},
computed: {
...mapState(['userInfo']),
},
mounted () {
setTimeout(() => { // 解决vant-tab组件官方问题底部条位置错误
this.utabs = true
}, 200)
},
components: {
musicPlay
},
methods: {
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
// 跳转
onPageJump(url) {
uni.navigateTo({
url: url
});
},
// 获取一级分类
getOneLevel() {
this.$http
.post('book/shopcategory/getOneLevel')
.then(res => {
//console.log(res,'一级分类')
this.oneLevel = res.list
// this.current = e.type
this.getTowLevel(this.oneLevel[0])
})
},
// 点击一级分类
getTowLevel(e) {
this.utabs = false
// this.twocurrent = 0;
uni.showLoading()
this.$http
.post(`book/shopcategory/getTwoLevel?catId=${e.catId}`)
.then(res => {
//console.log(res,'二级分类')
this.towLevel = res.list
if (this.towLevel == '') {
this.commodityList = []
} else {
let newo = {
catId:0,
name:'全部',
parentCid:e.catId
}
this.towLevel.splice(0,0,newo)
// this.getCategoryList(res.list[0])
// console.log(this.towLevel, 'towLevel')
this.getCategoryList(res.list[0])
}
uni.hideLoading()
this.utabs = true
uni.stopPullDownRefresh();
})
},
// 点击二级分类
getCategoryList(e) {
// console.log(e)
// return false
// this.highlight = index
this.$http
.post('book/shopproduct/appGetCategoryList', {
'catId': e.catId
})
.then(res => {
// console.log(res,'二级分类')
this.commodityList = res.list
})
},
// 加入购物车
addShopCar(e) {
this.$http
.post(`book/ordercart/getCartList?userId=${this.userInfo.id}`)
.then(res => {
// 获得用户的购物车列表信息
this.cartList = res.cartList
// 统计商品信息
let data = {
"userId": this.userInfo.id,
"productId": e.productId,
"productAmount": 1,
"price": e.price
}
// 判断列表是否为空
if (this.cartList.length > 0) {
let flag = ''
let shagnpin = {}
// 循环购物车列表
flag = this.cartList.some((item, index) => {
if (item.productId == data.productId) {
shagnpin = item
shagnpin.productAmount = item.productAmount + 1
return true
}
})
if (flag) {
// 已在购物车中添加
$http.request({
url: "book/ordercart/update",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: shagnpin,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
}
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
} else {
// 加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
}
} else {
// 购物车列表为空时直接加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
}
})
},
// 商品内容跳转
toDetail(id) {
uni.navigateTo({
url: `./commodityDetail?id=${id}`
})
}
},
onPullDownRefresh(){
// console.log('refresh');
this.commodityList = []
this.getOneLevel()
}
}
</script>
<style lang="scss" scoped>
.publierInfo {
display: inline-block;
background-color: #f1f1f1;
flex-direction: row;
border-radius: 10px;
vertical-align: middle;
padding: 0 12rpx;
line-height: 32rpx;
}
.c999 {
color: #999;
}
.f24 {
font-size: 24rpx;
}
.search_box {
width: 90%;
height: 64upx;
background-color: #fff;
border-radius: 32upx;
display: flex;
align-items: center;
padding: 0upx 40upx;
position: relative;
margin: 30rpx 0 15rpx -46%;
left: 50%;
box-shadow: 0 0px 10px 1px #54a96633;
.prompt {
color: #cccccc;
}
.icon_search {
background-image: url('@/static/icon/map_ic_search.png');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 29upx;
height: 28upx;
margin-right: 20upx;
}
}
.oneBox {
margin: 10rpx auto;
.oneLevel {}
}
.twoBox {
width: 95%;
margin: 0 auto;
}
.classfyBody {
margin: 5rpx auto;
// width: 100%;
height: 100%;
.towLevel {
width: 100%;
height: 100%;
display: flex;
.towLevelTitle {
width: 28%;
height: auto;
text-align: center;
.titleItem {
font-size: 35rpx;
padding: 20rpx 10rpx;
}
.active {
background-color: #fff;
border-left: solid 10rpx #eba00b;
font-weight: bold;
}
}
.towLevelContent {
display: flex;
flex-wrap: wrap;
padding: 10rpx 20rpx;
width: 100%;
align-items: stretch;
// align-content:center;
align-content:start;
.commodityItem {
width: 50%;
// background-color: #fff;
padding: 10rpx;
.box {
background-color: #fff;
padding: 10rpx;
border-radius: 20rpx !important;
overflow: hidden;
box-shadow: 0 0px 10px 1px #54a96633;
}
.commodityTitle {
font-size: 32rpx;
margin: 20rpx 0 10rpx 0;
}
image {
width: 100%;
border-radius: 10rpx;
height: 300rpx;
margin-right: 20rpx;
}
.commodityContent {
flex: 1;
font-size: 16px;
display: flex;
flex-direction: column;
justify-content: space-between;
.commodityPrice {
width: 100%;
position: relative;
margin: 0 0 3rpx 0;
.price {
vertical-align: middle;
color: #ffa200;
.priceTag {
flex-direction: row;
color: #999;
display: inline-block;
zoom: .8;
margin-left: 6rpx;
margin-bottom: 6px;
}
}
.SoldNumber {
font-size: 24rpx;
color: #999;
float: right;
margin-top: 16rpx;
}
.icon {
background-color: #fbf6ec;
border-radius: 50rpx;
padding: 5rpx;
position: absolute;
right: 0;
bottom: -20rpx;
}
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,78 @@
<template>
<view>
<z-nav-bar title="全部分类"></z-nav-bar>
<view class="oneLevel">
<view class="oneItem" v-for="(item,index) in oneLevel" @click="getTowLevel(index)">
<image :src="item.icon"></image>
<text>{{item.name}}</text>
</view>
</view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
export default {
data() {
return {
playData:{},
oneLevel: [],
}
},
onLoad(e) {
this.$http
.post('book/shopcategory/getOneLevel')
.then(res => {
let arr = []
for (let i in res.list) {
arr.push({
icon: "../../static/icon/shop_bar_" + (Number(i) + Number(1)) + ".png",
name: res.list[i].name,
catId: res.list[i].catId
})
}
this.oneLevel = arr
})
},
components: {
musicPlay
},
methods: {
// 点击分类跳转
getTowLevel(e) {
uni.navigateTo({
url: `./classify?type=${e}`
})
},
}
}
</script>
<style lang="scss" scoped>
.oneLevel {
margin: 10rpx 0 0 0;
.oneItem {
display: inline-block;
width: 20%;
text-align: center;
margin: 30rpx 0 0 0;
image {
width: 100rpx;
height: 100rpx;
margin: 0 auto;
}
text {
font-size: 30rpx;
}
}
}
</style>

View File

@@ -0,0 +1,630 @@
<template>
<view class="">
<view class="header">
<!-- 顶部导航栏 -->
<z-nav-bar title="商品详情" bgColor="red"></z-nav-bar>
</view>
<view class="swiperBox">
<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000"
style="width: 100%;height: 100%;">
<swiper-item v-for="(item,index) in swiperlist" :key="index" style="width: 100%;height: 100%;">
<image :src="item" mode="scaleToFill" style="width: 100%;height: 100%;"></image>
</swiper-item>
</swiper>
</view>
<view class="commodityContent">
<view class="commodityPrice">
<span></span><em>{{productInfo.price}}</em>
<span class="oldPrice " v-if="productInfo.activityPrice">原价{{productInfo.activityPrice}}</span>
</view>
<view class="commodityyName">
{{productInfo.productName}}
<span v-if="productInfo.productStock==0" style="color: #aaa;font-size:26rpx;">无货</span>
<view><text class="SoldNumber">已售<span>{{productInfo.sumSales}}</span></text></view>
</view>
<view class="contentButton">
<u-tabs :scrollable="false" :list="contentButtonList" @click="contentButtonClick"></u-tabs>
</view>
<!-- 详情 + 评价1 -->
<view v-if="contentShow == 0">
<view class="tingshuList" v-if="listenList.length > 0">
<h4>赠送听书权益</h4>
<view class="item flexbox" v-for="item in listenList" :key="item.id" style="vertical-align: middle;">
<text style="margin-top: 10rpx; padding-right: 10rpx;">{{item.name}}</text>
<u-icon v-if="item.canListen == 'true'" name="volume" color="#71d5a1" size="24" @click="goToListen(item.id)"></u-icon>
<u-icon v-else name="volume" color="#71d5a1" size="24" @click="goToListenNone(item.id)"></u-icon>
</view>
</view>
<view class="bookInfo" >
<u-row customStyle="margin-bottom: 10px">
<u-col ><span>书名{{productInfo.productName}}</span></u-col>
</u-row>
<u-row customStyle="margin-bottom: 10px">
<u-col v-if="productInfo.author"><span>作者{{productInfo.author}}</span></u-col>
</u-row>
<u-row>
<u-col span="6" v-if="productInfo.publisher"><span>出版社{{productInfo.publisher}}</span></u-col>
<u-col span="6" v-if="productInfo.pubDate"><span>出版时间{{ productInfo.pubDate | formatDate }}</span></u-col>
</u-row>
<u-row>
<u-col span="6" v-if="productInfo.format"><span>开本{{productInfo.format}}</span></u-col>
<u-col span="6" v-if="productInfo.pageNum"><span>页数{{productInfo.pageNum}}</span></u-col>
</u-row>
<u-row>
<u-col span="6" v-if="productInfo.quality"><span>内文用纸材质{{productInfo.quality}}</span></u-col>
</u-row>
</view>
<!-- <view class="commodityIntroduce" v-html="productInfo.productDetails"> -->
<view class="commodityIntroduce" >
<view v-if="productInfo.productDetails" >
<rich-text v-if="productInfo.productDetails" class="xiangqing" :nodes="productInfo.productDetails|formatRichText"></rich-text>
</view>
</view>
</view>
<view v-else >
<!-- 商品评价 -->
<view class="" v-if="commentsList && commentsList.length > 0">
<view class="pingjiaBox" v-for="(item, index) in commentsList" :key="index">
<view class="flexbox">
<view class="touxiang">
<image :src="item.avatar" mode="aspectFit"></image>
<text class="username nowrap ">{{item.name}}</text>
</view>
<view class="contentBox">
<view class="mb30">
<span :class="['star',item.starlevel >= 1 ? 'starLight':'starGray']"></span>
<span :class="['star',item.starlevel >= 2 ? 'starLight':'starGray']"></span>
<span :class="['star',item.starlevel >= 3 ? 'starLight':'starGray']"></span>
<span :class="['star',item.starlevel >= 4 ? 'starLight':'starGray']"></span>
<span :class="['star',item.starlevel >= 5 ? 'starLight':'starGray']"></span>
</view>
<div class="pjimgs flexbox">
<view class="item" v-for="(item1,index) in item.images">
<image v-if="item1.length > 10" @click="previewImage(item1)" :src="item1" mode="aspectFill" style="width:100%; height: 50px;"></image>
</view>
</div>
<view class="content" v-html="item.phtml"></view>
<text class="time">{{item.createdate}}</text>
</view>
</view>
<!-- 显示追平 -->
<view class="zhuiping item" v-if="item.zphtml != ''" style="padding-left: 50px;">
<h5 style="color: #dbdbdb; margin:10px;">追评内容</h5>
<view class="flexbox">
<view class="contentBox">
<view class="content" v-html="item.zphtml"></view>
<text class="time">{{item.followUpdate}}</text>
</view>
</view>
</view>
</view>
</view>
<view class="quesheng" v-else>
<text>暂无评价~</text>
</view>
</view>
<view style="height: 120rpx;"></view>
</view>
<uni-goods-nav class="goods_nav" :fill="true" :options="options" :buttonGroup="buttonGroup" @click="onClick"
@buttonClick="buttonClick" />
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import emojiList1 from '../../bkhumor-emojiplus/emoji/biaoqin.js'
import $http from '@/config/requestConfig.js';
import {
mapState
} from 'vuex';
import loginVue from '../user/login.vue';
export default {
data() {
return {
playData:{},
contentShow:0,
options: [{
icon: 'cart',
text: '购物车'
}],
buttonGroup: [{
text: '加入购物车',
backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)',
color: '#fff'
},
{
text: '立即购买',
backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
color: '#fff'
}
],
contentButtonList: [{
name: '商品详情'
},
{
name: '商品评价'
}
],
// 轮播图数据
swiperlist: [],
// 商品详情数据
productInfo: {},
productAmount: 1, // 商品数量
cartList: [], // 购物车列表
commentsList:[], // 评论列表
productId:null, // 商品评论
listenList:[] // 关联得听书
}
},
onLoad(e) {
this.productId = e.id
this.getProDetail(e)
this.getComments()
// console.log(emojiList1,'emojiList1')
},
computed: {
...mapState(['userInfo']),
},
components: {
musicPlay
},
methods: {
goToListen(id){
// 跳转到听书
uni.navigateTo({
url: "../listen/listen?bookid="+ id
});
},
// 放大图片
previewImage(url){
console.log(url)
uni.previewImage({
urls: [url]
});
},
// 获取html格式的评论1
getHtmlComment(comment){
// 格式化html
// console.log(comment,'comment')
// 这里处理 链接 换行符
let replacedStr = comment.replace(/\[([^(\]|\[)]*)\]/g, (item, index) => {
// console.log(item, index)
var indexss = emojiList1.findIndex(item1 => item1.alt === item)
// console.log(indexss, 'indexss')
return '<img src="https://www.nuttyreading.com/emojis/emojis/qq/' + emojiList1[indexss].url + '" width="18rpx">';
});
// console.log(replacedStr,'replacedStr')
return replacedStr.replace(/(\r\n)|(\n)/g, '<br>');
},
// 获取评价
getComments(){
$http.request({
url: "buy/record/All",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档1
data: {
'bookid': this.productId
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
if(res.code == 0){
console.log(res.list, 'res.list')
this.commentsList = res.list.map(item => {
var imgList = []
if(item.images !== null){
imgList = item.images.split(',')
item.images = imgList
return item
}else {
return item
}
})
// 评论格式化
var newarr = []
this.commentsList.forEach((item1)=>{
var pjstr = ''
var zpstr = ''
pjstr = this.getHtmlComment(item1.content)
item1.followUpcontent == '' ? zpstr = '' : zpstr = this.getHtmlComment(item1.followUpcontent)
//console.log(pjstr,'99999999999----------')
item1.phtml = pjstr
item1.zphtml = zpstr
newarr.push(item1)
})
this.commentsList = newarr
// console.log(this.commentsList,'评价+++++')
// this.commentsList = res.list
}
})
},
getProDetail(e){
// 获取商品详情
uni.showLoading({
title: '加载中'
});
console.log(e.id,'e.id')
this.$http
.post('/book/shopproduct/info/' + e.id)
.then(res => {
console.log('shopproduct',res)
this.productInfo = res.shopProduct
this.listenList = res.shopProduct.bookidsimages
if (this.productInfo.productImageList == null || this.productInfo.productImageList == '') {
this.swiperlist.push(this.productInfo.productImages)
} else {
let imgList = this.productInfo.productImageList.split(",")
// if(this.productInfo.productDetails != null){
// let info = this.formatRichText(this.productInfo.productDetails)
// }
// this.productInfo.productDetails = info
for (var i = 0; i < imgList.length; i++) {
this.swiperlist.push(imgList[i])
}
}
uni.hideLoading();
})
},
contentButtonClick(e){
this.contentShow = e.index
},
// 点击购物车
onClick(e) {
console.log(e.content.text)
uni.switchTab({
url: '../peanut/shopping'
});
},
// 点击按钮组间
buttonClick(e) {
console.log(e)
if(e.index == 0){
// 点击的是加入购物车
this.addCart()
}else{
// 点击的是立即购买
this.goPurse()
}
},
goToListenNone(){
uni.showToast({
title:'该书暂未生成音频内容,敬请期待!',
icon:'none'
})
},
// 加入购物车
addCart() {
if (this.productInfo.productStock == 0) {
uni.showToast({
title: '商品库存不足',
icon: "none",
duration: 1000,
});
} else {
this.$http
.post(`book/ordercart/getCartList?userId=${this.userInfo.id}`)
.then(res => {
this.cartList = res.cartList
this.isAdd()
})
}
},
isAdd() {
// 统计商品信息
let data = {
"userId": this.userInfo.id,
"productId": this.productInfo.productId,
"productAmount": this.productAmount,
"price": this.productInfo.price
}
// 判断列表是否为空
if (this.cartList.length > 0) {
let flag = ''
let shagnpin = {}
// 循环购物车列表
flag = this.cartList.some((item, index) => {
if (item.productId == data.productId) {
shagnpin = item
shagnpin.productAmount = item.productAmount + 1
return true
}
})
if (flag) {
// 已在购物车中添加
$http.request({
url: "book/ordercart/update",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: shagnpin,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
} else {
// 加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
}
} else {
// 购物车列表为空时直接加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
}
},
// 购买下单
goPurse() {
if (this.productInfo.productStock == 0) {
uni.showToast({
title: '商品库存不足',
icon: "none",
duration: 1000,
});
} else {
uni.navigateTo({
url: '../bookShop/settlement?type=2&list=' + this.productInfo.productId
});
}
},
formatRichText (html) { //控制小程序中图片大小
let newContent= html.replace(/<img[^>]*>/gi,function(match,capture){
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
return match;
});
newContent = newContent.replace(/style="[^"]+"/gi,function(match,capture){
match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;');
return match;
});
newContent = newContent.replace(/<br[^>]*\/>/gi, '');
newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
return newContent;
},
// 去购物车
goCard() {
uni.switchTab({
url: '../peanut/shopping'
});
},
},
filters: {/**
* 处理富文本里的图片宽度自适应
* 1.去掉img标签里的style、width、height属性
* 2.img标签添加style属性max-width:100%;height:auto
* 3.修改所有style里的width属性为max-width:100%
* 4.去掉<br/>标签
* @param html
* @returns {void|string|*}
*/
formatRichText (html) { //控制小程序中图片大小
let newContent= html.replace(/<img[^>]*>/gi,function(match,capture){
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
return match;
});
newContent = newContent.replace(/style="[^"]+"/gi,function(match,capture){
match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;');
return match;
});
newContent = newContent.replace(/<br[^>]*\/>/gi, '');
newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
return newContent;
},
// 时间格式化
formatDate(date){
console.log(date)
let newDate = new Date(date);
let year = newDate.getFullYear();
let month = newDate.getMonth().toString().padStart(2,0);
let day = newDate.getDay().toString().padStart(2,0);
return year + '-' + month + '-' + day;
}
}
}
</script>
<style lang="scss" scoped>
.tingshuList{margin-top: 20rpx; background-color: #fff; padding: 20rpx;
border-radius: 20rpx; margin-bottom: 20rpx; padding-top: 40rpx;
background-image: linear-gradient(0deg, #f7fffc 0%, #def0ea 100%);
.item{margin-bottom: 20rpx; vertical-align: middle; }
h4{color: #5fb386; font-size: 40rpx; margin-bottom: 20rpx;}
text{color: #444; font-size: 32rpx; padding-left: 20rpx;}
}
.pjimgs{ margin: 10px 0;flex-wrap: wrap; display: flex; justify-content: space-between;
.item{width: 23%; margin-right: 10px;
image{ }
}
}
.star{display: inline-block; width: 20px; height: 20px; margin-right: 10rpx;}
.starGray{ background : url(../../static/icon/star_greey.png) no-repeat; background-size: contain; }
.starLight{ background : url(../../static/icon/star_light.png) no-repeat; background-size: contain;}
.quesheng{text-align: center; margin-top: 100rpx; color: #8b8a91;}
.pingjiaBox{color: #555; margin-bottom: 20rpx;}
.flexbox{display: flex;}
.contentBox{width: calc(100% - 50px);box-sizing: border-box; padding-left: 20rpx;
.content{font-size: 28rpx; line-height: 40rpx;}
.time{font-size: 24rpx; color: #999; margin-top: 6rpx; float: right;}
}
.nowrap {
white-space: nowrap;
overflow-x: hidden;
text-overflow: ellipsis;
}
.touxiang{width:50px; overflow: hidden; text-align: center;
image{width:50px !important; padding: 3px; height: 50px !important; border: 1px solid #eee; border-radius: 64px; overflow: hidden;;}
.username{font-size: 24rpx; color: #999; margin-top: 6rpx; }
}
.xiangqing {
overflow: hidden; overflow-x: hidden;
img{display: block; max-width: 100%;}
p{max-width: 100%;}
}
.goods_nav {
z-index: 1;
position: fixed;
bottom: 0;
width: 100%;
}
.SoldNumber {
font-size: 24rpx;
color: #999;
margin-top: 16rpx;
}
.bookInfo {
padding: 20px 10px;
line-height: 30rpx;
background-color: #fff;
font-size: 26rpx;
color: #555;
border-radius: 20rpx 20rpx 0 0
}
.header {
position: fixed;
top: 0%;
left: 0%;
z-index: 999;
}
.contentButton {
margin: 10px 0;
}
.swiperBox {
width: 100%;
height: 375px;
margin-top: 150rpx;
}
.commodityContent {
margin: 30rpx 20rpx 10rpx 20rpx;
height: auto;
.commodityPrice {
background-image: linear-gradient(0deg, #f7fffc 0%, #def0ea 100%);
border-top: 1px solid #fff;
// background-color: #f7faf9;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
color: #ffa200;
padding: 20rpx 20rpx 40rpx 20rpx;
em {
font-size: 74rpx;
font-style: normal;
}
.oldPrice {
margin-left: 10rpx;
font-size: 32rpx;
color: #999;
}
}
.commodityyName {
margin-top: -20rpx;
padding: 30rpx 20rpx 40rpx 20rpx;
font-size: 40rpx;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
background-color: #fff;
}
.commodityIntroduce {
font-size: 30rpx;
background-color: #fff;
padding: 0 20rpx 30rpx 20rpx;
}
}
.footer {
width: 100%;
height: 100rpx;
background-color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
bottom: 0%;
.shopcard {
margin: 0 0 0 30rpx;
text-align: center;
font-size: 20rpx;
color: #eba00b;
}
.operate {
display: flex;
view {
font-size: 32rpx;
font-weight: 700;
color: #fff;
padding: 32rpx 40rpx;
letter-spacing: 0.8px;
}
.addShopCar {
background-color: #eba00b;
}
.goBuy {
background-color: #cf3906;
}
}
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,284 @@
<template>
<view>
<z-nav-bar>
<u-search :clearabled="true" bgColor="#fff" borderColor="#54a966" focus v-model="bookScreen.bookName"
@custom='souBook' @clear="clear"></u-search>
</z-nav-bar>
<view class="sear_ch" v-if="this.show==0">
<view class="sear_ch_tit">
历史搜索
</view>
<view class="sear_ch_tag">
<text v-for="item in historyList" @click="serkeyWord(item)">{{item}}</text>
</view>
</view>
<view class="sear_class" v-if="this.show==1">
<view class="sc_xuan">
<view class="sc_con" v-for="(item,index) in classFen" @click="FenBook(item)"
:class="bookScreen.type == item.id ? 'sc_con sc_con_style' : 'sc_con'">{{item.sort}}</view>
</view>
<view class="sc_xuan">
<view class="sc_con" v-for="(item,index) in classMian" @click="MianBook(item)"
:class="bookScreen.is_charge == item.id ? 'sc_con sc_con_style' : 'sc_con'">{{item.sort}}</view>
</view>
</view>
<view class="sear_list" v-if="this.show==1">
<view class="bl_tioa" v-for="(item,index) in bookList" @click="onBookJump(item)">
</view>
<view style="height: 1px;"></view>
<view>
<view v-if="status==0" style="text-align: center;">
<u-loading-icon style="display: inline-block;"></u-loading-icon>
<font style='vertical-align: super;margin-left: 10px;font-size: 26rpx;color: #909399;'>努力加载中</font>
</view>
<view v-if="status==1">
<u-divider text="全部加载完成"></u-divider>
</view>
</view>
<view v-if="this.show==1&&this.bookList==''">
<u-divider text="暂无数据"></u-divider>
</view>
<view style="padding-bottom: 20rpx;">
<u-back-top :scroll-top="scrollTop"></u-back-top>
</view>
</view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
export default {
data() {
return {
playData:{},
scrollTop: 0,
totalPage: 0,
status: 3,
show: 0,
bookList: [],
historyList: [],
bookScreen: {
authorName: '', //作者
publisherName: '', //出版社
type: '', //电子书类型
bookName: '', //关键词
is_charge: 1, //是否收费0收费1免费
state: 1,
page: 1, //当前页码数
limit: 10, //单页数据数量
},
classFen: [{
sort: '全部',
id: ''
}, {
sort: '医学',
id: 1
}, {
sort: '国学',
id: 2
}, {
sort: '文学',
id: 3
}, {
sort: '古籍',
id: 4
}],
classMian: [{
sort: '免费',
id: 1
}, {
sort: 'VIP',
id: 0
}],
};
},
// 返回顶部
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
// 下拉刷新
onReachBottom() {
this.status = 0
if (this.bookScreen.page < this.totalPage) {
this.bookScreen.page = this.bookScreen.page + 1
setTimeout(() => {
this.$http
.post('book/book/list', this.bookScreen)
.then(res => {
this.totalPage = res.page.totalPage
for (let i in res.page.list) {
this.bookList.push(res.page.list[i])
}
});
}, 1000)
} else {
this.status = 1
}
},
//第一次加载
onLoad(e) {
},
//页面显示
onShow() {
this.getHistory()
},
components: {
musicPlay
},
//方法
methods: {
// 获取缓存
getHistory() {
this.historyList = uni.getStorageSync('hisRecords')
if (this.historyList.length > 10) {
this.historyList.splice(10, this.historyList.length)
uni.setStorageSync('hisRecords', this.historyList);
}
},
// 获取列表数据
getData() {
this.$http
.post('book/book/list', this.bookScreen)
.then(res => {
this.bookList = res.page.list
this.totalPage = res.page.totalPage
this.status = 3
this.show = 1
});
},
// 清空
clear() {
this.show = 0
this.getHistory()
},
// 搜索
souBook() {
if (this.bookScreen.bookName == '') {
uni.showToast({
icon: 'none',
title: '请输入关键字'
})
return
}
this.getData();
let ArryList = []
if (uni.getStorageSync('hisRecords') == '') {
ArryList.push(this.bookScreen.bookName)
uni.setStorageSync('hisRecords', ArryList);
} else {
let value = uni.getStorageSync('hisRecords')
value.unshift(this.bookScreen.bookName)
uni.setStorageSync('hisRecords', value);
}
},
// 点击历史搜索
serkeyWord(e) {
this.bookScreen.bookName = e
this.getData();
},
},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.sear_ch {
margin: 50rpx 40rpx 0 40rpx;
.sear_ch_tit {
font-weight: bold;
font-size: 30rpx;
margin: 40rpx 0 0 0;
}
.sear_ch_tag {
margin: 20rpx 0 0 0;
text {
background-color: #eee;
font-size: 24rpx;
border-radius: 50rpx;
display: inline-block;
margin: 0 30rpx 20rpx 0;
padding: 10rpx 25rpx;
}
}
}
.sear_class {
margin: 20rpx 30rpx 60rpx 30rpx;
.sc_xuan {
margin-bottom: 10rpx;
.sc_con {
display: inline-block;
font-size: 28rpx;
margin-right: 20rpx;
border-radius: 20rpx;
padding: 6rpx 12rpx;
}
.sc_con_style {
color: #27b386;
background-color: #2ab58833;
}
}
}
.sear_list {
margin: 50rpx 30rpx 0 30rpx;
.bl_tioa {
box-shadow: 0 0px 10px 1px #d3d1d133;
background-color: #fff;
position: relative;
padding: 0 25upx 10upx 220upx;
margin: 0 0 60rpx 0;
border-radius: 15rpx;
min-height: 250rpx;
view {
text {
color: #9b9b9b;
font-size: 24rpx;
line-height: 36rpx;
}
.bok_name {
font-weight: bold;
color: #333;
font-size: 28rpx;
}
}
image {
position: absolute;
left: 30upx;
top: -20upx;
width: 160upx;
height: 240upx;
}
}
}
</style>

View File

@@ -0,0 +1,263 @@
<template>
<view class="">
<view class="header">
<!-- 顶部导航栏 -->
<z-nav-bar title="物流详情"></z-nav-bar>
</view>
<view class="" style="margin-bottom: 20rpx; font-size: 28rpx;">
<view class="kuaidiItem">运单号 {{expressOrderSn}}
<u-tag @click="copyData(expressOrderSn)" class="copyCode" text="复制" plain type="success" /></view>
</view>
<view v-if="deliverDetails.length > 0">
<!-- <u-tabs active-color="#2979ff" inactive-color="#606266" bar-height="6" bar-width="40"
name="name" :list="deliverList" :is-scroll="false" :current="current" @change="tabchange"></u-tabs> -->
<view class="deliverCntent">
<view class="">
<view v-for="(item, index) in deliverDetails" :class="['item',index == 0 ? 'first':'' ]">
<view class="flexbox">
<view class="img_icon "></view>
<view class="wuliu">
<view class="time">{{item.acceptTime}}</view>
<view class="content">{{item.acceptStation}}</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="quesheng" v-else>
<u-divider text="- 暂无物流信息 -"></u-divider>
</view>
<music-play :playData="playData"></music-play>
<public-module></public-module>
<!-- <u-loading color="red" :show="loading"></u-loading> -->
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
// import Loading from '../../'
import {
mapState
} from 'vuex';
import loginVue from '../user/login.vue';
export default {
data() {
return {
playData:{},
loading: false,
orderId: null,
deliverDetails: [],
express:{}, // 面单
consignee:{}, // 收件人信息
expressOrderSn:'', // 运单号
// expressCompanyCode:'', //快递编码
// expressCompanyName:'' ,// 快递公司
orderSn : '',
current: 0,
deliverList: [],
deliverDetailsLength: null,
orderContet:{},
}
},
onLoad(e) {
this.expressOrderSn = e.expressOrderSn
// this.expressCompanyCode = e.expressCompanyCode
// this.expressCompanyName = e.expressCompanyName
//this.express = e.express
//this.consignee = e.consignee
console.log(e,'传入的参数')
this.orderSn = e.orderSn
},
onShow() {
this.getOrderList()
},
computed: {
...mapState(['userInfo']),
},
components:{
musicPlay
},
methods: {
// 获取订单列表
getOrderList() {
console.log('this.orderType',this.orderType)
this.$http
// .get(`book/buyOrder/getOrderInfo?orderId=${this.orderID}`)
.get(`book/buyOrder/orderDetail?orderSn=${this.orderSn}`)
.then(res => {
console.log('订单详情',res)
var seconds = res.result.timestamp + 30 * 60 + 2 // 过期时间
var nowSeconds = Math.floor(new Date().getTime() / 1000);
res.result.overTime = seconds - nowSeconds
this.orderContet = res.result
//this.userRecordid = res.userRecordid
this.productIDs = res.result.goodsList.map(item => {
return item.buyOrderProductId
})
// console.log(this.orderContet,'this.orderContet')
if (this.orderContet.orderStatus == 0) {
this.titleStat = '待支付'
} else if (this.orderContet.orderStatus == 1) {
this.titleStat = '待发货'
} else if (this.orderContet.orderStatus == 2) {
this.titleStat = '待收货'
} else if (this.orderContet.orderStatus == 3) {
this.titleStat = '已完成'
}
if(parseInt(this.orderContet.orderStatus) >= 2){
this.getdeliverDetails()
// 查询快递信息
// this.getSheetInfo()
}
console.log(this.orderContet,'订单详情')
})
},
// 复制到剪切板
copyData(data){
uni.setClipboardData({
data,
success: function () {
console.log('success');
}
});
},
tabchange(item) {
console.log(item)
this.current = item.index
},
// 获取物流
getdeliverDetails() {
this.deliverList = []
// var strLength = this.orderContet.consignee.consigneeMobile.length
// var subMobile = this.orderContet.consignee.consigneeMobile.substring(strLength-4,strLength)
// this.expressOrderSn = 'SF1504651506851'
// this.expressCompanyCode = 'SF'
// subMobile = '9277'
uni.showLoading()
this.$http
//.post(`/book/buyOrder/queryFMS?orderId=${this.orderId}`)
.get(`/book/buyOrder/searchExpress?expressOrderSn=${this.expressOrderSn}`)
.then(res => {
console.log(res, '物流信息')
if (res && res.code === 0) {
uni.hideLoading()
// this.deliverDetails = res.result.traces
console.log(res.express.traces,'物流信息')
if(res.express.traces.length > 0){
this.deliverDetails = res.express.traces.reverse()
}else{
this.deliverDetails = []
}
}
}).catch(e => {
uni.hideLoading()
console.log(e,'e')
})
},
}
}
</script>
<style>
.item:first-child::before {
background-color: #6fca78 !important
}
</style>
<style lang="scss" scoped>
.quesheng{text-align: center; margin-top: 20px;
image{ width: 150rpx; height: 170rpx; display: block; margin: 10px auto;
}
text{
color: #888;
}
}
.copyCode{display: inline-block; margin-left: 20rpx; }
.u-tabs {
background: #fff
}
.xiangqing {
overflow: hidden;
img {
display: block;
max-width: 100%;
}
}
.kuaidiItem {
padding: 10px;
color: #666
}
.deliverCntent {
.img_icon {
border-left: 2px solid #eee;
}
line-height:20px;
padding: 32rpx;
position: relative;
background-color: #fff;
margin-bottom: 20rpx;
border-top: 1px solid #eee;
font-size: 28rpx;
color:#777;
.item {
padding-left: 10px;
position: relative;
}
.item:before {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 100%;
background: #eee;
left: 6px;
top: 0;
content: "";
position: absolute;
}
.time {
color: #888;
font-size: 28rpx;
margin-bottom: 5px
}
.first{
color: #55aa7f;
}
.content {
padding-bottom: 14px;
}
}
.flexbox {
display: flex;
}
.img_icon {
padding-right: 30rpx;
}
.moreBtnF {
align-items: center;
padding: 30rpx;
height: 100%;
position: absolute;
right: 0;
top: 0;
z-index: 1;
background-color: rgba(255, 255, 255, .9);
}
</style>

View File

@@ -0,0 +1,22 @@
<template>
<view>
快递列表页面
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,801 @@
<template>
<view>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<!-- <z-nav-bar title="我的订单"></z-nav-bar> -->
<z-nav-bar backState="2000" title="我的订单"></z-nav-bar>
<view class="orderTabs flexbox">
<view v-for="(item,index) in orderTabs" @click="orderTabCLi(item.value)"
:class="orderListTab==item.value?'ordStyle':''">{{item.name}}</view>
</view>
<view class="orderList" v-if="orderList.length > 0">
<view class="orderItem" v-for="(ifex,inten) in orderList" @click="goOrdiCont(ifex)" :key="inten">
<text class="orderState orderState0" v-if="ifex.orderStatus==0">待支付</text>
<text class="orderState orderState1" v-if="ifex.orderStatus==1">待发货</text>
<text class="orderState orderState2" v-if="ifex.orderStatus==2">待收货</text>
<text class="orderState orderState3" v-if="ifex.orderStatus==3">已完成</text>
<text class="orderState orderState5" v-if="ifex.orderStatus==5">已超时</text>
<view class="guoqi flexbox" v-if="ifex.orderStatus==0 && ifex.overTime > 0">
<text>剩余支付时间</text>
<uni-countdown background-color="#ff5500" color="#ffffff" :font-size="14" :show-day="false"
:hour="0" :minute="0" :second="ifex.overTime" @timeup="countDown"></uni-countdown>
</view>
<view class="flexbox orderSn">
<text class="">订单编号: {{ifex.orderSn}}</text>
</view>
<view class="orderContent" :key="index" v-if="ifex.orderType=='order'"
v-for="(item,index) in ifex.productList">
<image :src="item.product.productImages" mode=""></image>
<view class="itemJian">
<view class="orderTitle">
<text>{{item.product.productName}}</text>
</view>
<view class="orderPrice">
<text style="color: #f56c6c;"></text><text
style="font-weight: bold; color: #f56c6c;">{{item.product.price}}</text><br>
<text style="color: #bbbbbb;font-size: 20rpx;margin-right: 10rpx;">X</text>
<text style="color: #bbbbbb;">{{item.quantity}}</text>
</view>
<br clear="both">
</view>
<br clear="both">
</view>
<view class="orderContent" v-if="ifex.orderType=='point'" @click.stop="goOrdiCont(ifex)">
<image src="../../static/icon/oder_chong.png" mode="" style="height: 150rpx;"></image>
<view class="itemJian">
<view class="orderTitle">
<text>天医币充值</text>
</view>
<view class="orderPrice">
<text style="color: #f56c6c;"></text><text
style="font-weight: bold; color: #f56c6c;">{{ifex.realMoney}}</text>
</view>
<br clear="both">
</view>
<br clear="both">
</view>
<view class="orderContent" v-if="ifex.orderType=='vip'" @click.stop="goOrdiCont(ifex)">
<image src="../../static/icon/oder_vip.png" mode="" style="height: 150rpx;"></image>
<view class="itemJian">
<view class="orderTitle">
<text>会员充值</text>
</view>
<view class="orderPrice">
<text style="color: #f56c6c;"></text><text
style="font-weight: bold; color: #f56c6c;">{{ifex.realMoney}}</text>
</view>
<br clear="both">
</view>
<br clear="both">
</view>
<view class="orderReal">
<span style="color: #999; float: left; font-size: 12px;">下单时间{{ifex.createTime}}</span>
<span style="color: #999;margin-right: 10rpx;">实付款 : </span>
<span style=" color: #f56c6c;"></span><text
style="font-weight: bold; color: #f56c6c;">{{ifex.realMoney}}</text>
</view>
<view class="orderOper" v-if="ifex.orderStatus==0">
<view class="opFix" @click.stop = "canceOrder(ifex)">取消订单</view>
<view class="opCan" @click.stop = "getNewIap" v-if="ifex.orderType == 'point' && ifex.paymentMethod == '3'">重新下单</view>
<view class="opCan" v-else @click.stop = "goPay(ifex)">去支付</view>
</view>
</view>
<view v-if="status==0" style="text-align: center;">
<u-loading-icon style="display: inline-block;"></u-loading-icon>
<font style='vertical-align: super;margin-left: 10px;font-size: 26rpx;color: #909399;'>努力加载中</font>
</view>
<view v-if="status==1" style="padding-bottom: 20rpx;">
<u-divider text="全部加载完成"></u-divider>
</view>
</view>
<view class="" v-else style=" margin-top: 250rpx;">
<u-divider text="暂无订单数据"></u-divider>
</view>
<z-navigation></z-navigation>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
import {
setPay,
setPayAssign,
setWXPay
} from '@/config/utils';
import {
mapState,
mapMutations
} from 'vuex';
export default {
data() {
return {
playData: {},
orderTabs: [{
name: '全部',
value: null
}, {
name: '待支付',
value: 0
}, {
name: '待发货',
value: 1
}, {
name: '待收货',
value: 2
}, {
name: '已完成',
value: 3
}, {
name: '已超时',
value: 5
}, ],
orderListTab: null,
orderList: [],
iapChannel: {},
checking: false, // 正在检测
ComplateRequestArr: null,
isAndorid: true,
status: 3, // 加载状态
totalPage: 0,
page: 1
}
},
onHide() {
this.orderList = [],
this.page = 1
this.totalPage = 0
this.orderListTab = null
},
onShow() {
this.getOrderList()
// this.checkIapOrders() //检查未完成的苹果支付订单
this.getOS()
// this.countDown()
},
computed: {
...mapState(['userInfo']),
},
// 下拉刷新
onPullDownRefresh() {
this.orderList = [],
this.page = 1
this.totalPage = 0
this.getOrderList()
uni.stopPullDownRefresh()
},
onReachBottom() {
console.log('到底了')
if (this.page < this.totalPage) {
this.page++
// console.log('加载',this.page)
this.status = 0
this.getOrderList()
} else {
this.status = 1
console.log('加载完成了', this.page)
return
}
},
components: {
musicPlay
},
methods: {
...mapMutations(['setUserInfo']),
// 苹果用户重新下单
getNewIap(){
uni.navigateTo({
url:'/pages/peanut/reCharge'
})
},
// 倒计时回调
countDown() {
console.log('重新刷新订单')
this.totalPage = 0
this.page = 1
this.orderList = []
this.getOrderList()
},
// 获得操作系统
getOS() {
let oprateOs = ''
oprateOs = uni.getSystemInfoSync().platform
console.log(oprateOs)
if (oprateOs == 'android') {
this.isAndorid = true
} else {
this.isAndorid = false
}
},
checkIapOrders() {
const that = this
// 如果ios已经绑定支付信息就直接支付如果没有绑定就需要先绑定
console.log('检测支付环境...')
plus.payment.getChannels((channels) => {
console.log(channels, 'channels')
for (var i in channels) {
// 判断是否苹果支付1
if (channels[i].id === 'appleiap') {
that.iapChannel = channels[i]
that.restoreComplateRequest() // 检查未关闭订单
// that.requestOrder(productId)
}
}
})
},
// 切换订单状态
orderTabCLi(e) {
this.orderListTab = e
this.totalPage = 0
this.page = 1
this.orderList = []
this.getOrderList()
},
// 获取订单列表
getOrderList() {
let data = {
"userId": "",
"orderStatus": this.orderListTab,
"page": this.page,
"limit": 10,
'userId': this.userInfo.id
}
$http.request({
// url: "book/buyOrder/orderList",
url: "book/buyOrder/getUserOrderList",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
res.page.records.forEach((item, index) => {
var seconds = item.timestamp + 30 * 60 + 2 // 过期时间 30分钟+2
// var seconds = item.timestamp + 30 + 2 // 过期时间 30秒
var nowSeconds = Math.floor(new Date().getTime() / 1000); // 单位秒
item.overTime = seconds - nowSeconds
// console.log(item.overTime,'item.overTime')
})
this.orderList = this.orderList.concat(res.page.records)
this.totalPage = res.page.pages
if (res.page.pages == this.page) {
this.status = 1
} else {
this.status = 3
}
console.log(this.orderList, '订单列表')
}
})
},
// 订单详情
goOrdiCont(e) {
console.log(e, 'e')
//let orderId = e.orderId ? e.orderId : e.id
if(e.orderType == 'point'){ // 充值订单
console.log('跳转到充值页面')
uni.navigateTo({
url: '/pages/peanut/chargeDetaill?orderId=' + e.orderId + '&orderSn=' + e.orderSn
});
}else if(e.orderType == 'order'){ // 实体订单
uni.navigateTo({
url: './orderLCont?orderId=' + e.orderId + '&orderType=' + e.orderStatus + '&orderSn=' + e.orderSn
});
}
},
// 跳转到支付页面
goPay1(e) {
console.log(e, 'goPay1')
uni.navigateTo({
url: '../peanut/reCharge?orderSn=' + e.orderSn
});
},
// 取消订单
canceOrder(e) {
uni.showModal({
title: '提示',
content: '确定要取消订单吗?',
confirmText: "取消订单",
cancelText: "考虑一下",
confirmColor: '#c96713',
cancelColor: '#555',
success: res => {
if (res.confirm) {
this.$http
.post(`book/buyOrder/appDelete?orderId=${e.orderId}`)
.then(res => {
uni.showToast({
icon: 'none',
title: '取消订单成功'
})
this.page = 1
this.totalPage = 0
this.orderList = []
this.getOrderList()
})
}
}
});
},
// 支付
goPay(payItem) {
console.log(payItem, 'payItem')
if (payItem.paymentMethod == 2) {
console.log('阿里支付')
setPay({
typePay: 'alipay',
subject: 'order',
totalAmount: payItem.realMoney,
type: 2,
relevanceoid: payItem.orderSn,
customerId: this.userInfo.id,
}, res => {
if (res.success) {
uni.showToast({
title: "支付成功"
});
} else {
uni.showToast({
title: "支付失败",
icon: "none",
image: '../../static/icon/ic_close.png'
});
}
this.orderList = [],
this.page = 1
this.totalPage = 0
this.getOrderList()
})
} else if (payItem.paymentMethod == 1) {
console.log('微信支付')
// console.log(this.isAndorid)
if (this.isAndorid == false) {
uni.showModal({
title: '提示',
content: '很抱歉,苹果系统暂不支持微信支付',
showCancel: false
})
return false
} else {
let data1 = {
orderSn: payItem.orderSn,
buyOrderId: null,
totalAmount: payItem.realMoney
}
console.log(data1, 'data1')
setWXPay(data1, res => {
if (res.success) {
uni.showToast({
title: "支付成功"
});
} else {
console.log(res)
if (res.data.errMsg.indexOf('User canceled') != -1) {
uni.showToast({
title: "用户取消支付",
icon: "none",
image: '../../static/icon/ic_close.png'
});
} else {
uni.showToast({
title: "支付失败",
icon: "none",
image: '../../static/icon/ic_close.png'
});
}
}
})
}
} else if (payItem.paymentMethod == 3) {
// 苹果充值
console.log('苹果二次支付')
if (this.isAndorid) {
uni.showModal({
title: '提示',
showCancel: false,
content: '很抱歉,当前订单属于苹果系统内购订单,安卓系统无法完成支付操作,您可切换到苹果系统进行支付,也可以取消该订单,并重新下单'
})
} else {
this.iphonepay(payItem)
}
}
},
iphonepay(payItem) {
console.log(this.userInfo.restoreFlag, 'this.userInfo.restoreFlag')
if (this.ComplateRequestArr == null || this.ComplateRequestArr == []) {
this.requestOrder(payItem)
} else {
uni.showModal({
title: '提示',
showCancel: false,
content: '您的账户存在未完成的支付订单请稍后重启app留意账户变动。',
})
}
},
requestOrder(payItem) {
uni.showLoading({
title: '获取商品信息',
mask: true
})
const that = this
// console.log(productId, 88888888)
// ['xxxxx'] 是平台申请拿到的内购商品的id
let IAPOrders = []
IAPOrders.push(payItem.productId + '')
console.log(IAPOrders, 'IAPOrders')
// 新建订单
that.iapChannel.requestOrder(IAPOrders, function(event) {
// uni.hideLoading()
console.log(event, 'event')
for (var index in event) {
var OrderItem = event[index]
// console.log(OrderItem, 'OrderItem')
console.log(OrderItem.productid, 'OrderItem.productid')
that.topay(payItem)
}
}, function(erroemsg) {
uni.showToast({
title: "商品获取失败",
icon: 'none'
})
})
},
topay(payItem) {
const that = this
uni.hideLoading()
// var restoreFlag = true; // 调用支付接口时标记 restoreFlag = true , 实际应用请将标记存储在 storage 中
this.setUserInfo({
restoreFlag: true
});
console.log(this.userInfo, '更新后的用户信息')
plus.payment.request(that.iapChannel, {
productid: payItem.productId,
username: payItem.orderSn, // 用户标识/订单标识
manualFinishTransaction: true // 3.5.1+ 支持,设置此参数后需要开发者主动关闭订单,参见下面的关闭订单方法 finishTransaction()
}, function(result) {
// restoreFlag = false; // 支付成功清除标记 restoreFlag = false
that.transaction = result
// 支付成功result 为 IAP商品交易信息对象 IAPTransaction 需将返回的支付凭证传给后端进行二次认证
that.iapCheck(result)
}, function(e) {
if (e.errCode == 2) {
// 用户未绑定支付方式app内支付流程结束系统弹出框引导用户绑定支付方式此过程将跳转到系统应用 AppStore 进行绑定支付方式,绑定成功同步支付成功,用户成功付款
// plus.runtime.openURL("https://apps.apple.com/account/billing");
} else {
// restoreFlag = false; // 支付失败清楚标记
that.finishTransaction(result);
//console.log('订单关闭后的用户信息', that.userInfo);
// console.log(e)
//console.log(e.message)
}
});
},
// 查询未关闭订单
restoreComplateRequest() {
let that = this
console.log('检测未完成订单')
// console.log(that.iapChannel,'this.iapChannel')
that.iapChannel.restoreComplateRequest({
manualFinishTransaction: true
}, function(results) {
console.log('进入restoreComplateRequest')
// if(!that.checking){
// that.checking = true
// console.log(that.checking)
// results 格式为数组存放恢复的IAP商品交易信息对象 IAPTransaction通用需将返回的支付凭证传给后端进行二次认证
that.ComplateRequestArr = results
console.log(that.ComplateRequestArr, '未完成订单数组')
if (results && results.length > 0) {
results.map((item, index) => {
// "0"为正在支付;"1"为支付成功;"2"为支付失败;"3"为支付已恢复。
if (item.transactionState == '1') {
// 已经支付,但是没有走逻辑的内购订单
that.iapCheck(item, index)
} else {
// 其他状态的内购订单
that.finishTransaction(item)
}
})
} else {
this.setUserInfo({
restoreFlag: false
});
console.log('无未处理订单,可以拉起新的支付')
}
// }
});
},
// 关闭交易订单
finishTransaction(trans, index) {
this.iapChannel.finishTransaction(trans, (success) => {
console.log('关闭订单成功', index);
if (index == this.ComplateRequestArr.length - 1) { // 最后一个支付订单
this.setUserInfo({
restoreFlag: false
});
console.log(this.userInfo.restoreFlag, 'this.userInfo.restoreFlag')
}
}, (fail) => {
console.log('关闭订单失败');
});
},
iapCheck(result, index) {
const that = this
console.log('进入后台验证')
let data = {
transactionId: result.transactionIdentifier, // 支付交易id
customerOid: that.userInfo.id,
productId: result.payment.productid, // 产品id
orderId: result.payment.username, // 系统订单号
receiptData: result.transactionReceipt, // 苹果返回收据
loadAnimate: 'none', // 请求加载动画
}
console.log(data, 'data')
$http.request({
url: "/Ipa/veri",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
console.log(JSON.stringify(res))
console.log(res.code)
if (res.code == 0) {
// uni.hideLoading()
console.log('充值订单已处理,请留意账户金额变动....')
// 服务器验证票据有效后在客户端关闭订单
that.finishTransaction(result, index)
} else if (res.code == 200) { // 重复验证订单
console.log('重复验证....')
that.finishTransaction(result, index)
}
}).catch(e => {
console.log('支付验证失败,进入轮询程序...')
that.getIapPayResult(result, index)
})
console.log('--------------')
},
// 轮询验证支付结果
getIapPayResult(result, index) {
// let interval = null
this.ComplateRequestInterval = setTimeout(() => {
if (this.maxTimes <= 3) {
this.iapCheck(result, index)
console.log('执行1', this.maxTimes, this.ComplateRequestInterval)
this.maxTimes += 1
} else {
this.maxTimes = 0
console.log('停止轮询', this.maxTimes, this.ComplateRequestInterval, this.maxTimes)
this.checking = false
this.saveErrorIapOrder(result, index)
clearTimeout(this.ComplateRequestInterval)
}
}, 10000)
},
// 轮询失败接口
saveErrorIapOrder(result, index) {
console.log('提交到充值问题单里面...')
let data = {
transactionId: result.transactionIdentifier,
failureflag: 1,
orderId: result.payment.username,
receiptData: result.transactionReceipt,
productId: result.payment.productid,
customerOid: this.userInfo.id
}
$http.request({
url: "Ipa/failure",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
console.log(JSON.stringify(res))
if (res.code == 200) {
console.log('提交成功,关闭订单')
this.finishTransaction(result, index)
}
}).catch(e => {
console.log(e)
if (e.statusCode == 0) { // 重复提交,直接关闭订单
this.finishTransaction(result, index)
}
})
},
}
}
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.guoqi {
font-size: 28rpx;
align-items: center;
color: red;
float: right;
line-height: 40rpx;
}
.flexbox {
display: flex;
}
.orderTabs {
margin: 60rpx 0 0 0;
width: 100%;
padding: 30rpx 3% 3% 3%;
// padding-top: 100rpx;
position: fixed;
top: 80rpx;
background-color: #fff;
z-index: 100;
view {
border-radius: 20rpx;
border: 1px solid #d0d0d0;
display: inline-block;
padding: 20rpx 0;
margin: 0 6rpx;
// margin: 40rpx 0 15rpx 0;
width: 20%;
text-align: center;
font-size: 30rpx;
}
.ordStyle {
background: #f0f9eb;
border: 2rpx solid #54a966;
color: #54a966;
font-weight: bold;
}
}
.orderList {
padding: 20rpx;
margin-top: 130rpx;
.orderItem {
position: relative;
padding: 30rpx 10rpx 30rpx 30rpx;
background-color: #fff;
border-radius: 30rpx;
margin-bottom: 30rpx;
.orderSn {
font-size: 26rpx;
color: #999;
padding-bottom: 20rpx;
border-bottom: 1px solid #eee;
margin-top: 60rpx;
margin-bottom: 30rpx;
}
.orderState {
color: #fff;
position: absolute;
left: 0;
top: 20rpx;
padding: 10rpx;
border-radius: 0 24rpx 24rpx 0;
font-size: 26rpx;
// font-weight: bold;
color: #fff;
}
.orderState0 {
background-color: #e6a23c;
}
.orderState1 {
background-color: #409eff;
}
.orderState2 {
background-color: #f56c6c;
}
.orderState3 {
background-color: #67c23a;
}
.orderState5 {
background-color: #787878;
}
.orderContent {
margin-bottom: 20rpx;
image {
width: 130rpx;
height: 140rpx;
margin-right: 20rpx;
float: left;
}
.itemJian {
float: left;
width: 470rpx;
.orderTitle {
// font-weight: bold;
font-size: 28rpx;
margin: 0 0 20rpx 0;
float: left;
width: 410rpx;
}
.orderPrice {
font-size: 28rpx;
float: right;
width: 60rpx;
text-align: right;
line-height: 40rpx;
}
}
}
.orderReal {
border-top: 1px solid #eee;
text-align: right;
font-size: 30rpx;
margin: 30rpx 20rpx 0 0;
padding: 30rpx 0 0 0;
}
.orderOper {
text-align: right;
margin: 30rpx 20rpx 0 0;
view {
margin-left: 20rpx;
padding: 10rpx 0;
display: inline-block;
width: 150rpx;
font-size: 25rpx;
text-align: center;
}
.opFix {
color: #555;
border: 1px solid #ddd;
border-radius: 30rpx;
}
.opCan {
color: #c96713;
border: 1px solid #eba00b;
border-radius: 30rpx;
}
}
}
}
</style>

1230
pages/bookShop/orderList.vue Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff