Initial commit: 积分兑换电商平台多商户版 MER-2.2

Made-with: Cursor
This commit is contained in:
apple
2026-03-08 20:07:52 +08:00
commit de02c8a3e1
4954 changed files with 703009 additions and 0 deletions

View File

@@ -0,0 +1,308 @@
<template>
<view :data-theme="theme" @touchmove.stop.prevent="disabledScroll">
<view class="address-window" :class="display==true?'on':''">
<view class='title'>请选择所在地区<text class='iconfont icon-ic_close1' @tap='close'></text></view>
<view class="address-count">
<view class="address-selected">
<view v-for="(item,index) in selectedArr" :key="index" class="selected-list"
:class="{active:index === selectedIndex}" @click="change(item, index)">
{{item.regionName?item.regionName:'请选择'}}
<text class="iconfont icon-ic_rightarrow"></text>
</view>
<view class="selected-list" :class="{active:-1 === selectedIndex}" v-if="showMore"
@click="change(-1, -1)">
<text class="iconfont icon-ic_rightarrow"></text>
请选择
</view>
</view>
<scroll-view scroll-y="true" :scroll-top="scrollTop" class="address-list" @scroll="scroll">
<view v-for="(item,index) in addressList" :key="index" class="list"
:class="{active:item.regionId === activeId}" @click="selected(item, index)">
<text class="item-name">{{item.regionName}}</text>
<text v-if="item.regionId === activeId" class="iconfont icon-duihao2"></text>
</view>
</scroll-view>
</view>
</view>
<view class='mask' catchtouchmove="true" @touchmove.prevent :hidden='display==false'
@tap='close'></view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
getCity
} from '@/api/api.js';
const CACHE_ADDRESS = {};
let app = getApp();
export default {
props: {
display: {
type: Boolean,
default: true
},
cityShow: {
type: Number,
default: 3
},
address: {
type: Array,
default: []
}
},
data() {
return {
theme: app.globalData.theme,
active: 0,
//地址列表
addressList: [],
selectedArr: [],
selectedIndex: -1,
is_loading: false,
old: {
scrollTop: 0
},
scrollTop: 0,
addressData: [],
province: [],
city: [],
district: [],
street: []
};
},
computed: {
activeId() {
return this.selectedIndex == -1 ? 0 : this.selectedArr[this.selectedIndex].regionId
},
showMore() {
return this.selectedArr.length ? (this.selectedArr[this.selectedArr.length - 1].isChild && ((this
.cityShow == 1 && this.addressList.regionType < 2) ||
(this.cityShow == 2 && this.addressList.regionType < 3) || (this.cityShow == 3 && this
.addressList
.regionType < 4))) : true
}
},
watch: {
address(n) {
this.selectedArr = n ? [...n] : []
},
display(n) {
if (!n) {
this.addressList = [];
this.selectedArr = this.address ? [...this.address] : [];
this.selectedIndex = -1;
this.is_loading = false;
} else {
this.loadAddress(1, 1)
}
}
},
mounted() {
this.loadAddress(1, 1);
},
methods: {
disabledScroll() {
return
},
loadAddress(parentId, regionType) {
if (CACHE_ADDRESS[parentId]) {
this.addressList = CACHE_ADDRESS[parentId];
return;
}
let data = {
parentId: parentId,
regionType: regionType
}
this.is_loading = true;
getCity(data).then(res => {
this.is_loading = false;
CACHE_ADDRESS[parentId] = res.data;
this.addressList = res.data;
})
this.goTop()
},
change(item, index) {
if (this.selectedIndex == index) return;
this.selectedIndex = index;
this.loadAddress(item.parentId, item.regionType);
},
selected(item, index) {
if (this.is_loading) return;
if (this.selectedIndex > -1) {
this.selectedArr.splice(this.selectedIndex + 1, 999)
this.selectedArr[this.selectedIndex] = item;
this.selectedIndex = -1;
} else if (item.regionType === 1) {
this.selectedArr = [item];
} else {
this.selectedArr.push(item);
}
if (item.isChild && ((this.cityShow == 1 && this.addressList[0].regionType < 2) || (this.cityShow == 2 &&
this
.addressList[0].regionType < 3) || (this.cityShow == 3 && this.addressList[0].regionType < 4))) {
this.loadAddress(item.regionId, item.regionType + 1);
} else {
this.$emit('submit', [...this.selectedArr]);
this.$emit('changeClose');
}
this.goTop()
},
close: function() {
this.$emit('changeClose');
},
scroll: function(e) {
this.old.scrollTop = e.detail.scrollTop
},
goTop: function(e) {
this.scrollTop = this.old.scrollTop
this.$nextTick(() => {
this.scrollTop = 0
});
}
}
}
</script>
<style scoped lang="scss">
.address-window {
background-color: #fff;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
z-index: 101;
border-radius: 30rpx 30rpx 0 0;
transform: translate3d(0, 100%, 0);
transition: all .3s cubic-bezier(.25, .5, .5, .9);
}
.address-window.on {
transform: translate3d(0, 0, 0);
}
.address-window .title {
font-size: 32rpx;
font-weight: bold;
text-align: center;
height: 123rpx;
line-height: 123rpx;
position: relative;
}
.address-window .title .iconfont {
position: absolute;
right: 30rpx;
color: #8a8a8a;
font-size: 35rpx;
}
.address-count {
.address-selected {
padding: 0 30rpx;
margin-top: 10rpx;
position: relative;
padding-bottom: 20rpx;
border-bottom: 2rpx solid #f7f7f7;
}
.selected-list {
font-size: 26rpx;
color: #282828;
line-height: 50rpx;
padding-bottom: 10rpx;
padding-left: 60rpx;
position: relative;
&.active {
color: #e28d54;
}
&:before,
&:after {
content: '';
display: block;
position: absolute;
}
&:before {
width: 4rpx;
height: 100%;
@include main_bg_color(theme);
top: 0;
left: 10rpx;
}
&:after {
width: 12rpx;
height: 12rpx;
@include main_bg_color(theme);
border-radius: 100%;
left: 6rpx;
top: 50%;
margin-top: -8rpx;
}
&:first-child,
&:last-child {
&:before {
height: 50%;
}
}
&:first-child {
&:before {
top: auto;
bottom: 0;
}
}
.iconfont {
font-size: 20rpx;
float: right;
color: #dddddd;
}
}
scroll-view {
height: 700rpx;
}
.address-list {
padding: 0 30rpx;
margin-top: 20rpx;
box-sizing: border-box;
.list {
.iconfont {
float: right;
color: #ddd;
font-size: 22rpx;
}
.item-name {
display: inline-block;
line-height: 50rpx;
margin-bottom: 20rpx;
font-size: 26rpx;
}
&.active {
color: #e28d54;
.iconfont {
color: #e28d54;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,173 @@
<template>
<view :data-theme="theme">
<!-- 选择送货方式 -->
<view class="mask-box">
<view class="bg" v-if="isShowBox"></view>
<view class="mask-content animated" :class="{slideInUp:isShowBox}">
<view class="title-bar">
配送方式
<CloseIcon @handle-close="closeShowBox" topStyle="top:40rpx"></CloseIcon>
</view>
<view class="box">
<view class="check-item" v-for="(item,index) in radioList" :key="index" :class="{on:index == radioIndex}">
<view>{{item.title}}</view>
<view class="radio" @click="bindCheck(item,index)">
<block v-if="newData.shippingType === item.shippingType">
<view class="iconfont icon-a-ic_CompleteSelect"></view>
</block>
<block v-else>
<view class="iconfont icon-ic_unselect"></view>
</block>
</view>
</view>
</view>
<view class="foot">
<view class="btn" @click="confirmBtn">确定</view>
</view>
</view>
</view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import { mapGetters } from "vuex";
let app = getApp();
export default{
name:'checkDelivery',
props:{
isShowBox:{
type:Boolean,
default:false
},
activeObj:{
type:Object,
default:function(){
return {}
}
}
},
data(){
return {
radioList:[
{
title:'商家配送',
shippingType: 1
},
{
title:'到店自提',
shippingType: 2
}
],
radioIndex:0,
oldRadioIndex:'', //旧的索引
newData:{},
theme: app.globalData.theme,
shippingType: 1,
deliveryNameNew: '',
}
},
created() {
this.newData = JSON.parse(JSON.stringify(this.activeObj));
},
methods:{
// 关闭配送方式弹窗
closeShowBox(){
this.$emit('close')
},
// 选择配送方式
bindCheck(item,index){
this.deliveryNameNew = item.title;
this.newData.shippingType = item.shippingType;
},
confirmBtn(){
this.$emit('confirmBtn',this.newData)
}
}
}
</script>
<style lang="scss" scoped>
.mask-box{
.bg{
z-index: 99;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
}
.mask-content{
z-index: 999;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #fff;
border-radius: 40rpx 40rpx 0 0;
transform: translate3d(0, 100%, 0);
transition: all .3s cubic-bezier(.25, .5, .5, .9);
.title-bar{
position: relative;
text-align: center;
padding: 30rpx 0;
margin-bottom: 20rpx;
font-size: 32rpx;
color: #282828;
.close{
position: absolute;
right: 30rpx;
top: 50%;
transform: translateY(-50%);
.iconfont{
color: #8A8A8A;
}
}
}
.box{
padding: 0 30rpx;
.check-item{
display: flex;
align-items: center;
justify-content: space-between;
height: 40rpx;
margin-bottom: 50rpx;
font-size: 28rpx;
.iconfont{
font-size: 38rpx;
color: #CCCCCC;
&.icon-a-ic_CompleteSelect{
@include main_color(theme);
}
}
}
}
.foot{
padding: 15rpx 30rpx;
.btn{
width: 100%;
height: 70rpx;
line-height: 70rpx;
text-align: center;
border-radius: 35rpx;
color: #fff;
font-size: 30rpx;
@include main_bg_color(theme);
}
}
}
}
.animated {
animation-duration: .3s
}
</style>

View File

@@ -0,0 +1,351 @@
<template>
<view>
<view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
<CloseIcon @handle-close="close" topStyle="top:auto"></CloseIcon>
<view class="_tit text-center">选择优惠券</view>
<view class='coupon-list' :style="{'margin-top':!orderShow?'0':'0'}">
<view v-if="couponList.length">
<view style="padding-bottom: 70rpx;">
<view class='item acea-row row-center-wrapper' @click="getCouponUser(index,item)" v-for="(item,index) in couponList"
:key='index'>
<view class='money acea-row row-column row-center-wrapper' :class='!item.isChoose&&!item.isChecked?"moneyGray":"main_bg"'>
<view><text class='num'>{{item.money?Number(item.money):''}}</text></view>
<view class="pic-num">{{item.minPrice}}元可用</view>
</view>
<view class='text'>
<view class='acea-row condition'>
<span class='line-title select'
:class='!item.isChoose?"gray":"select"'>{{item.category | couponTypeFilter}}</span>
<span class="line2">{{item.name}}</span>
</view>
<view class='data acea-row row-between-wrapper'>
<view v-if="coupon.statusTile">{{$util.getCouponTime(item.startTime,item.endTime)}}</view>
<view>
<view v-if="!item.isChecked && item.isChoose" class="iconfont icon-ic_unselect f-s-36 text--w111-ccc"></view>
<view v-if="item.isChecked && item.isChoose" class='iconfont icon-a-ic_CompleteSelect font-color f-s-36'></view>
<view v-if="!item.isChoose && !item.isChecked" class="noCheck f-s-36"></view>
</view>
</view>
</view>
</view>
</view>
<view class="foot-box">
<view v-if="Number(couponMoney)>0" class="left">
可优惠<text class="font-color">{{couponMoney}}</text>
</view>
<view v-else class="left"></view>
<view @click="onSure" class="btn bg-color">确定</view>
</view>
</view>
<!-- 无优惠券 -->
<view class='pictrue' v-if="!couponList.length">
<image :src="urlDomain+'crmebimage/presets/noCoupon.png'"></image>
<view class="default_txt">暂无优惠券哦~</view>
</view>
</view>
</view>
<view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
setCouponReceive
} from '@/api/api.js';
export default {
props: {
//打开状态 0=领取优惠券,1=使用优惠券
openType: {
type: Number,
default: 0,
},
coupon: {
type: Object,
default: function() {
return {};
}
},
//下单页面使用优惠券组件不展示tab切换页
orderShow: {
type: String,
default: function() {
return '';
}
},
typeNum: {
type: Number,
default: 0
},
//平台优惠券可使用的门槛
surplusFee: {
type: Number,
default: 0
}
},
data() {
return {
type: 1,
current: 0,
urlDomain: this.$Cache.get("imgHost"),
couponList: [],
couponMoney: 0,
couponObj: {}, //修改过的数据
};
},
watch: {
coupon:{
handler(nVal,oVal){
this.couponList = JSON.parse(JSON.stringify(nVal.list));
this.couponList.map(i=>{
if(i.isChecked){
this.couponMoney =i.money
}else{
this.couponMoney = 0
}
});
},
immediate: true,
deep:true
}
},
mounted() {
},
methods: {
close: function() {
this.type = this.typeNum;
this.$emit('ChangCouponsClone');
},
//确定选择优惠券
onSure() {
this.$emit('ChangCoupons', this.couponObj);
},
//选择优惠券
getCouponUser: function(index, item) {
if(!item.isChecked && !item.isChoose) return;
this.couponList.map(i=>{
if(!item.isChecked)i.isChecked = false
});
item.isChecked = !item.isChecked;
this.couponMoney = item.isChecked ? item.money : 0;
this.couponObj = item;
},
setType: function(type) {
this.$emit('tabCouponType', type);
this.type = type;
}
}
}
</script>
<style scoped lang="scss">
.noCheck {
width: 32rpx;
height: 32rpx;
border-radius: 50%;
overflow: hidden;
border: 1px solid #999999;
background-color: #eee;
}
.foot-box {
width: 100%;
height: 100rpx;
background: #FFFFFF;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30rpx;
position: absolute;
bottom: 0;
.btn {
width: 144rpx;
height: 68rpx;
line-height: 68rpx;
text-align: center;
border-radius: 50rpx;
color: #fff;
font-size: 26rpx;
}
.left {
text {
color: var(--view-priceColor);
}
}
}
/deep/.uni-radio-input-checked {
@include main_bg_color(theme);
}
._tit {
font-size: 32rpx;
font-weight: 600;
color: #282828;
margin-bottom: 43rpx;
}
.icon-guanbi5 {
position: absolute;
font-size: 28rpx;
color: #aaa;
top: 30rpx;
right: 30rpx;
z-index: 1;
}
.width {
width: 252rpx;
}
.coupon-list {
padding-left: 0 !important;
padding-right: 0 !important;
}
.coupon-list-window {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #f5f5f5;
border-radius: 40rpx 40rpx 0 0;
z-index: 9999;
transform: translate3d(0, 100%, 0);
transition: all .3s cubic-bezier(.25, .5, .5, .9);
padding-top: 43rpx;
}
.coupon-list-window.on {
transform: translate3d(0, 0, 0);
}
.coupon-list-window .title {
height: 124rpx;
width: 100%;
text-align: center;
line-height: 124rpx;
font-size: 32rpx;
font-weight: bold;
position: relative;
}
.coupon-list-window .title .iconfont {
position: absolute;
right: 30rpx;
top: 50%;
transform: translateY(-50%);
font-size: 35rpx;
color: #8a8a8a;
font-weight: normal;
}
.coupon-list-window .coupon-list {
margin: 0 0 30rpx 0;
height: 823rpx;
overflow: auto;
}
.coupon-list-window .pictrue {
width: 414rpx;
height: 336rpx;
margin: 208rpx auto;
}
.coupon-list-window .pictrue image {
width: 100%;
height: 100%;
}
.pic-num {
color: #fff;
font-size: 24rpx;
}
.line-title {
width: 90rpx;
padding: 0 10rpx;
box-sizing: border-box;
background: #fff;
border: 1px solid rgba(232, 51, 35, 1);
opacity: 1;
border-radius: 20rpx;
font-size: 20rpx;
color: #E83323;
margin-right: 12rpx;
}
.line-title.gray {
border-color: #BBB;
color: #bbb;
background-color: #F5F5F5;
}
.nav {
// position: absolute;
// top: 0;
// left: 0;
width: 100%;
height: 96rpx;
border-bottom: 2rpx solid #F5F5F5;
border-top-left-radius: 16rpx;
border-top-right-radius: 16rpx;
background-color: #FFFFFF;
font-size: 30rpx;
color: #999999;
}
.nav .acea-row {
border-top: 5rpx solid transparent;
border-bottom: 5rpx solid transparent;
}
.nav .acea-row.on {
@include tab_border_bottom(theme);
color: #282828;
}
.nav .acea-row:only-child {
border-bottom-color: transparent;
}
.occupy {
height: 106rpx;
}
.coupon-list .item {
margin-bottom: 20rpx;
.data {
padding-top: 20rpx;
}
}
.coupon-list .item .money {
font-weight: normal;
}
.select {
@include main_color(theme);
@include coupons_border_color(theme);
}
.default_txt {
font-size: 26rpx;
color: #999;
text-align: center;
}
</style>

View File

@@ -0,0 +1,201 @@
<template>
<view class="previewImg" v-if="showBox" @touchmove.stop.prevent>
<view class="mask" @click="close">
<swiper @change="changeSwiper" class="mask-swiper" :current="currentIndex" :circular="circular"
:duration="duration">
<swiper-item v-for="(src, i) in list" :key="i" class="flex flex-column justify-center align-center">
<image class="mask-swiper-img" :src="src.image" mode="widthFix" />
<view class="mask_sku">
<text class="sku_name mb-34">{{src.sku}}</text>
<PointsPrice v-if="src.type === ProductTypeEnum.Integral" :pointsPrice="src"
:pointsGoodsStyle="hotPointsStyle"></PointsPrice>
<view v-else>
<text class="sku_price">{{!type?src.price:src.groupPrice}}</text>
</view>
</view>
</swiper-item>
</swiper>
</view>
<view class="pagebox" v-if="list.length>0">{{ Number(currentIndex) + 1 }} / {{ list.length }}</view>
<!-- #ifndef MP -->
<text class="iconfont icon-ic_share share_btn" @click="shareFriend()"></text>
<!-- #endif -->
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import PointsPrice from '@/components/PointsPrice.vue';
import {
ProductTypeEnum
} from "@/enums/productEnums";
export default {
name: 'cus-previewImg',
components: {
PointsPrice
},
props: {
list: {
type: Array,
required: true,
default: () => {
return [];
}
},
circular: {
type: Boolean,
default: true
},
duration: {
type: Number,
default: 500
}
},
data() {
return {
ProductTypeEnum: ProductTypeEnum,
hotPointsStyle: {
iconStyle: {
width: '32rpx',
height: '32rpx'
},
priceStyle: {
fontSize: '32rpx',
},
unitStyle: {
fontSize: '28rpx',
},
priceColor: {
color: '#fff'
}
},
currentIndex: 0,
showBox: false,
type: 0,
};
},
methods: {
// 左右切换
changeSwiper(e) {
this.currentIndex = e.target.current;
this.$emit('changeSwitch', e.target.current)
},
open(current, type) {
if (type) {
this.type = type
}
if (!current || !this.list.length) return;
this.currentIndex = this.list.map((item) => item.sku).indexOf(current);
this.showBox = true;
},
close() {
this.showBox = false;
},
shareFriend() {
this.$emit('shareFriend')
}
}
}
</script>
<style lang="scss" scoped>
/deep/.price-box{
color: #fff !important;
}
@mixin full {
width: 100%;
height: 100%;
}
.previewImg {
position: fixed;
top: 0;
left: 0;
z-index: 300;
@include full;
.mask {
display: flex;
justify-content: center;
align-items: center;
background-color: #000;
opacity: 1;
z-index: 8;
@include full;
&-swiper {
@include full;
&-img {
width: 100%;
}
}
}
.pagebox {
position: absolute;
width: 100%;
bottom: 20rpx;
z-index: 300;
color: #fff;
text-align: center;
}
}
.mask_sku {
color: #fff;
max-width: 80%;
z-index: 300;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 90rpx;
.sku_name {
font-size: 12px;
border: 1px solid #fff;
padding: 10rpx 30rpx 10rpx;
border-radius: 40px;
box-sizing: border-box;
}
.sku_price {
padding-top: 10px;
}
}
.font12 {
font-size: 24rpx;
}
.share_btn {
position: absolute;
top: 70rpx;
right: 50rpx;
font-size: 40rpx;
color: #fff;
z-index: 300;
}
.flex-column {
flex-direction: column;
}
.justify-center {
justify-content: center;
}
.align-center {
align-items: center;
}
</style>

View File

@@ -0,0 +1,280 @@
<template>
<view>
<view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
<CloseIcon @handle-close="close" topStyle="top:auto"></CloseIcon>
<view class="_tit text-center">领取优惠券</view>
<view class='coupon-list borderPad' :style="{'margin-top':!orderShow?'0':'0'}">
<block v-if="coupon.list.length">
<view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list"
@click="getCouponUser(index,item.id)" :key='index'>
<view class='money acea-row row-column row-center-wrapper main_bg'>
<view><text class='num'>{{item.money?Number(item.money):''}}</text></view>
<view class="pic-num">{{item.minPrice}}元可用</view>
</view>
<view class='text'>
<view class='acea-row condition'>
<span v-if='item.merId===0' class='line-title select'>平台</span>
<span v-else class='line-title select'>店铺</span>
<span class="line2">{{item.name}}</span>
</view>
<view class='data acea-row row-between-wrapper'>
<view class="width">
<view v-if="item.isFixedTime" class="_end">
{{ $util.getTime(item.useStartTimeStr) + ' - ' + $util.getTime(item.useEndTimeStr) + ' 可用' }}
</view>
<view v-else class="_end">{{ '领取后' + item.day + '天内可用' }}</view>
</view>
<view class='bnt main_bg' v-if="!item.isUse">{{coupon.statusTile || '立即领取'}}</view>
</view>
<span v-if="item.isUse" class="iconfont icon-ic_yilingqu font-color"></span>
</view>
</view>
</block>
<!-- 无优惠券 -->
<view class='pictrue' v-else>
<image :src="urlDomain+'crmebimage/presets/noCoupon.png'"></image>
<view class="default_txt">暂无优惠券哦~</view>
</view>
</view>
</view>
<view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
setCouponReceive
} from '@/api/api.js';
export default {
props: {
//打开状态 0=领取优惠券,1=使用优惠券
openType: {
type: Number,
default: 0,
},
coupon: {
type: Object,
default: function() {
return {};
}
},
//下单页面使用优惠券组件不展示tab切换页
orderShow: {
type: String,
default: function() {
return '';
}
},
typeNum: {
type: Number,
default: 0
}
},
data() {
return {
type: 1,
urlDomain: this.$Cache.get("imgHost")
};
},
watch: {
'coupon.type': function(val) { //监听props中的属性
this.type = val;
}
},
methods: {
close: function() {
this.type = this.typeNum;
this.$emit('ChangCouponsClone');
},
getCouponUser: function(index, id) {
let that = this;
let list = that.coupon.list;
if (list[index].isUse == true && this.openType == 0) return true;
switch (this.openType) {
case 0:
//领取优惠券
let ids = [];
ids.push(id);
setCouponReceive(id).then(res => {
that.$emit('ChangCouponsUseState', index);
that.$util.Tips({
title: "领取成功"
}, function(res) {
return that.$util.Tips({
title: res
});
});
that.$emit('ChangCoupons', list[index]);
}).catch(err => {
that.$util.Tips({
title: err,
});
})
break;
case 1:
that.$emit('ChangCoupons', index);
break;
}
},
setType: function(type) {
this.$emit('tabCouponType', type);
this.type = type;
}
}
}
</script>
<style scoped lang="scss">
.icon-ic_yilingqu {
position: absolute;
opacity: 0.1;
font-size: 160rpx;
top: 50rpx;
right: -20rpx;
}
._tit {
font-size: 32rpx;
font-weight: 600;
color: #282828;
margin-bottom: 43rpx;
}
.icon-guanbi5 {
position: absolute;
font-size: 28rpx;
color: #aaa;
top: 30rpx;
right: 30rpx;
z-index: 1;
}
.coupon-list-window {
padding-top: 46rpx;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #f5f5f5;
border-radius: 40rpx 40rpx 0 0;
z-index: 555;
transform: translate3d(0, 100%, 0);
transition: all .3s cubic-bezier(.25, .5, .5, .9);
}
.coupon-list-window.on {
transform: translate3d(0, 0, 0);
}
.coupon-list-window .title {
height: 124rpx;
width: 100%;
text-align: center;
line-height: 124rpx;
font-size: 32rpx;
font-weight: bold;
position: relative;
}
.coupon-list-window .title .iconfont {
position: absolute;
right: 30rpx;
top: 50%;
transform: translateY(-50%);
font-size: 35rpx;
color: #8a8a8a;
font-weight: normal;
}
.coupon-list-window .coupon-list {
margin: 0 0 30rpx 0;
height: 823rpx;
overflow: auto;
.text {
position: relative;
overflow: hidden;
}
}
.coupon-list-window .pictrue {
width: 414rpx;
height: 336rpx;
margin: 208rpx auto;
}
.coupon-list-window .pictrue image {
width: 100%;
height: 100%;
}
.pic-num {
color: #fff;
font-size: 24rpx;
}
.line-title.gray {
border-color: #BBB;
color: #bbb;
background-color: #F5F5F5;
}
.nav {
width: 100%;
height: 96rpx;
border-bottom: 2rpx solid #F5F5F5;
border-top-left-radius: 16rpx;
border-top-right-radius: 16rpx;
background-color: #FFFFFF;
font-size: 30rpx;
color: #999999;
}
.nav .acea-row {
border-top: 5rpx solid transparent;
border-bottom: 5rpx solid transparent;
}
.nav .acea-row.on {
@include tab_border_bottom(theme);
color: #282828;
}
.nav .acea-row:only-child {
border-bottom-color: transparent;
}
.coupon-list .item {
margin-bottom: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
}
.coupon-list .item .money {
font-weight: normal;
}
.select {
@include main_color(theme);
@include coupons_border_color(theme);
}
.default_txt {
font-size: 26rpx;
color: #999;
text-align: center;
}
</style>

View File

@@ -0,0 +1,814 @@
<!--
parser 主模块组件
githubhttps://github.com/jin-yufeng/Parser
docshttps://jin-yufeng.github.io/Parser
插件市场https://ext.dcloud.net.cn/plugin?id=805
authorJinYufeng
update2020/04/14
-->
<template>
<view>
<slot v-if="!nodes.length" />
<!--#ifdef APP-PLUS-NVUE-->
<web-view id="top" ref="web" :src="src" :style="'margin-top:-2px;height:'+height+'px'" @onPostMessage="_message" />
<!--#endif-->
<!--#ifndef APP-PLUS-NVUE-->
<view id="top" :style="showAm+(selectable?';user-select:text;-webkit-user-select:text':'')" :animation="scaleAm" @tap="_tap"
@touchstart="_touchstart" @touchmove="_touchmove">
<!--#ifdef H5-->
<div :id="'rtf'+uid"></div>
<!--#endif-->
<!--#ifndef H5-->
<trees :nodes="nodes" :lazy-load="lazyLoad" :loadVideo="loadVideo" />
<image v-for="(item, index) in imgs" v-bind:key="index" :id="index" :src="item" hidden @load="_load" />
<!--#endif-->
</view>
<!--#endif-->
</view>
</template>
<script>
// #ifndef H5 || APP-PLUS-NVUE
import trees from './libs/trees';
var cache = {},
// #ifdef MP-WEIXIN || MP-TOUTIAO
fs = uni.getFileSystemManager ? uni.getFileSystemManager() : null,
// #endif
Parser = require('./libs/MpHtmlParser.js');
var document; // document 补丁包 https://jin-yufeng.github.io/Parser/#/instructions?id=document
// 计算 cache 的 key
function hash(str) {
for (var i = str.length, val = 5381; i--;)
val += (val << 5) + str.charCodeAt(i);
return val;
}
// #endif
// #ifdef H5 || APP-PLUS-NVUE
var rpx = uni.getSystemInfoSync().screenWidth / 750,
cfg = require('./libs/config.js');
// #endif
// #ifdef APP-PLUS-NVUE
var dom = weex.requireModule('dom');
// #endif
export default {
name: 'parser',
data() {
return {
// #ifdef APP-PLUS
loadVideo: false,
// #endif
// #ifdef H5
uid: this._uid,
// #endif
// #ifdef APP-PLUS-NVUE
src: '',
height: 1,
// #endif
// #ifndef APP-PLUS-NVUE
scaleAm: '',
showAm: '',
imgs: [],
// #endif
nodes: []
}
},
// #ifndef H5 || APP-PLUS-NVUE
components: {
trees
},
// #endif
props: {
'html': null,
// #ifndef MP-ALIPAY
'autopause': {
type: Boolean,
default: true
},
// #endif
'autosetTitle': {
type: Boolean,
default: true
},
// #ifndef H5 || APP-PLUS-NVUE
'compress': Number,
'useCache': Boolean,
'xml': Boolean,
// #endif
'domain': String,
// #ifndef MP-BAIDU || MP-ALIPAY || APP-PLUS
'gestureZoom': Boolean,
// #endif
// #ifdef MP-WEIXIN || MP-QQ || H5 || APP-PLUS
'lazyLoad': Boolean,
// #endif
'selectable': Boolean,
'tagStyle': Object,
'showWithAnimation': Boolean,
'useAnchor': Boolean
},
watch: {
html(html) {
this.setContent(html);
}
},
mounted() {
// 图片数组
this.imgList = [];
this.imgList.each = function(f) {
for (var i = 0, len = this.length; i < len; i++)
this.setItem(i, f(this[i], i, this));
}
this.imgList.setItem = function(i, src) {
if (i == void 0 || !src) return;
// #ifndef MP-ALIPAY || APP-PLUS
// 去重
if (src.indexOf('http') == 0 && this.includes(src)) {
var newSrc = '';
for (var j = 0, c; c = src[j]; j++) {
if (c == '/' && src[j - 1] != '/' && src[j + 1] != '/') break;
newSrc += Math.random() > 0.5 ? c.toUpperCase() : c;
}
newSrc += src.substr(j);
return this[i] = newSrc;
}
// #endif
this[i] = src;
// 暂存 data src
if (src.includes('data:image')) {
var filePath, info = src.match(/data:image\/(\S+?);(\S+?),(.+)/);
if (!info) return;
// #ifdef MP-WEIXIN || MP-TOUTIAO
filePath = `${wx.env.USER_DATA_PATH}/${Date.now()}.${info[1]}`;
fs && fs.writeFile({
filePath,
data: info[3],
encoding: info[2],
success: () => this[i] = filePath
})
// #endif
// #ifdef APP-PLUS
filePath = `_doc/parser_tmp/${Date.now()}.${info[1]}`;
var bitmap = new plus.nativeObj.Bitmap();
bitmap.loadBase64Data(src, () => {
bitmap.save(filePath, {}, () => {
bitmap.clear()
this[i] = filePath;
})
})
// #endif
}
}
if (this.html) this.setContent(this.html);
},
beforeDestroy() {
// #ifdef H5
if (this._observer) this._observer.disconnect();
// #endif
this.imgList.each(src => {
// #ifdef APP-PLUS
if (src && src.includes('_doc')) {
plus.io.resolveLocalFileSystemURL(src, entry => {
entry.remove();
});
}
// #endif
// #ifdef MP-WEIXIN || MP-TOUTIAO
if (src && uni.env && src.includes(uni.env.USER_DATA_PATH))
fs && fs.unlink({
filePath: src
})
// #endif
})
clearInterval(this._timer);
},
methods: {
// #ifdef H5 || APP-PLUS-NVUE
_Dom2Str(nodes) {
var str = '';
for (var node of nodes) {
if (node.type == 'text')
str += node.text;
else {
str += ('<' + node.name);
for (var attr in node.attrs || {})
str += (' ' + attr + '="' + node.attrs[attr] + '"');
if (!node.children || !node.children.length) str += '>';
else str += ('>' + this._Dom2Str(node.children) + '</' + node.name + '>');
}
}
return str;
},
_handleHtml(html, append) {
if (typeof html != 'string') html = this._Dom2Str(html.nodes || html);
// 处理 rpx
if (html.includes('rpx'))
html = html.replace(/[0-9.]+\s*rpx/g, $ => parseFloat($) * rpx + 'px');
if (!append) {
// 处理 tag-style 和 userAgentStyles
var style = '<style>@keyframes show{0%{opacity:0}100%{opacity:1}}';
for (var item in cfg.userAgentStyles)
style += `${item}{${cfg.userAgentStyles[item]}}`;
for (item in this.tagStyle)
style += `${item}{${this.tagStyle[item]}}`;
style += '</style>';
html = style + html;
}
return html;
},
// #endif
setContent(html, append) {
// #ifdef APP-PLUS-NVUE
if (!html) {
this.src = '';
this.height = 1;
return;
}
if (append) return;
plus.io.resolveLocalFileSystemURL('_doc', entry => {
entry.getDirectory('parser_tmp', {
create: true
}, entry => {
var fileName = Date.now() + '.html';
entry.getFile(fileName, {
create: true
}, entry => {
entry.createWriter(writer => {
writer.onwriteend = () => {
this.nodes = [1];
this.src = '_doc/parser_tmp/' + fileName;
this.$nextTick(function() {
entry.remove();
})
}
html =
'<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1' +
(this.selectable ? '' : ',user-scalable=no') +
'"><script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></' +
'script><base href="' + this.domain + '">' + this._handleHtml(html) +
'<script>"use strict";function post(t){uni.postMessage({data:t})}' +
(this.showWithAnimation ? 'document.body.style.animation="show .5s",' : '') +
'document.addEventListener("UniAppJSBridgeReady",function(){post({action:"load",text:document.body.innerText});var t=document.getElementsByTagName("title");t.length&&post({action:"getTitle",title:t[0].innerText});for(var e,o=document.getElementsByTagName("img"),n=[],i=0,r=0;e=o[i];i++)e.onerror=function(){post({action:"error",source:"img",target:this})},e.hasAttribute("ignore")||"A"==e.parentElement.nodeName||(e.i=r++,n.push(e.src),e.onclick=function(){post({action:"preview",img:{i:this.i,src:this.src}})});post({action:"getImgList",imgList:n});for(var a,s=document.getElementsByTagName("a"),c=0;a=s[c];c++)a.onclick=function(){var t,e=this.getAttribute("href");if("#"==e[0]){var r=document.getElementById(e.substr(1));r&&(t=r.offsetTop)}return post({action:"linkpress",href:e,offset:t}),!1};;for(var u,m=document.getElementsByTagName("video"),d=0;u=m[d];d++)u.style.maxWidth="100%",u.onerror=function(){post({action:"error",source:"video",target:this})}' +
(this.autopause ? ',u.onplay=function(){for(var t,e=0;t=m[e];e++)t!=this&&t.pause()}' : '') +
';for(var g,l=document.getElementsByTagName("audio"),p=0;g=l[p];p++)g.onerror=function(){post({action:"error",source:"audio",target:this})};window.onload=function(){post({action:"ready",height:document.body.scrollHeight})}});</' +
'script>';
writer.write(html);
});
})
})
})
// #endif
// #ifdef H5
if (!html) {
if (this.rtf && !append) this.rtf.parentNode.removeChild(this.rtf);
return;
}
var div = document.createElement('div');
if (!append) {
if (this.rtf) this.rtf.parentNode.removeChild(this.rtf);
this.rtf = div;
} else {
if (!this.rtf) this.rtf = div;
else this.rtf.appendChild(div);
}
div.innerHTML = this._handleHtml(html, append);
for (var styles = this.rtf.getElementsByTagName('style'), i = 0, style; style = styles[i++];) {
style.innerHTML = style.innerHTML.replace(/body/g, '#rtf' + this._uid);
style.setAttribute('scoped', 'true');
}
// 懒加载
if (!this._observer && this.lazyLoad && IntersectionObserver) {
this._observer = new IntersectionObserver(changes => {
for (let item, i = 0; item = changes[i++];) {
if (item.isIntersecting) {
item.target.src = item.target.getAttribute('data-src');
item.target.removeAttribute('data-src');
this._observer.unobserve(item.target);
}
}
}, {
rootMargin: '900px 0px 900px 0px'
})
}
var _ts = this;
// 获取标题
var title = this.rtf.getElementsByTagName('title');
if (title.length && this.autosetTitle)
uni.setNavigationBarTitle({
title: title[0].innerText
})
// 图片处理
this.imgList.length = 0;
var imgs = this.rtf.getElementsByTagName('img');
for (let i = 0, j = 0, img; img = imgs[i]; i++) {
img.style.maxWidth = '100%';
var src = img.getAttribute('src');
if (this.domain && src) {
if (src[0] == '/') {
if (src[1] == '/')
img.src = (this.domain.includes('://') ? this.domain.split('://')[0] : '') + ':' + src;
else img.src = this.domain + src;
} else if (!src.includes('://')) img.src = this.domain + '/' + src;
}
if (!img.hasAttribute('ignore') && img.parentElement.nodeName != 'A') {
img.i = j++;
_ts.imgList.push(img.src || img.getAttribute('data-src'));
img.onclick = function() {
var preview = true;
this.ignore = () => preview = false;
_ts.$emit('imgtap', this);
if (preview) {
uni.previewImage({
current: this.i,
urls: _ts.imgList
});
}
}
}
img.onerror = function() {
_ts.$emit('error', {
source: 'img',
target: this
});
}
if (_ts.lazyLoad && this._observer && img.src && img.i != 0) {
img.setAttribute('data-src', img.src);
img.removeAttribute('src');
this._observer.observe(img);
}
}
// 链接处理
var links = this.rtf.getElementsByTagName('a');
for (var link of links) {
link.onclick = function() {
var jump = true,
href = this.getAttribute('href');
_ts.$emit('linkpress', {
href,
ignore: () => jump = false
});
if (jump && href) {
if (href[0] == '#') {
if (_ts.useAnchor) {
_ts.navigateTo({
id: href.substr(1)
})
}
} else if (href.indexOf('http') == 0 || href.indexOf('//') == 0)
return true;
else {
uni.navigateTo({
url: href
})
}
}
return false;
}
}
// 视频处理
var videos = this.rtf.getElementsByTagName('video');
_ts.videoContexts = videos;
for (let video, i = 0; video = videos[i++];) {
video.style.maxWidth = '100%';
video.onerror = function() {
_ts.$emit('error', {
source: 'video',
target: this
});
}
video.onplay = function() {
if (_ts.autopause)
for (let item, i = 0; item = _ts.videoContexts[i++];)
if (item != this) item.pause();
}
}
// 音频处理
var audios = this.rtf.getElementsByTagName('audios');
for (var audio of audios)
audio.onerror = function() {
_ts.$emit('error', {
source: 'audio',
target: this
});
}
this.document = this.rtf;
if (!append) document.getElementById('rtf' + this._uid).appendChild(this.rtf);
this.$nextTick(() => {
this.nodes = [1];
this.$emit('load');
})
setTimeout(() => this.showAm = '', 500);
// #endif
// #ifndef H5 || APP-PLUS-NVUE
var nodes;
if (!html)
return this.nodes = [];
else if (typeof html == 'string') {
let parser = new Parser(html, this);
// 缓存读取
if (this.useCache) {
var hashVal = hash(html);
if (cache[hashVal])
nodes = cache[hashVal];
else {
nodes = parser.parse();
cache[hashVal] = nodes;
}
} else nodes = parser.parse();
this.$emit('parse', nodes);
} else if (Object.prototype.toString.call(html) == '[object Array]') {
// 非本插件产生的 array 需要进行一些转换
if (html.length && html[0].PoweredBy != 'Parser') {
let parser = new Parser(html, this);
(function f(ns) {
for (var i = 0, n; n = ns[i]; i++) {
if (n.type == 'text') continue;
n.attrs = n.attrs || {};
for (var item in n.attrs)
if (typeof n.attrs[item] != 'string') n.attrs[item] = n.attrs[item].toString();
parser.matchAttr(n, parser);
if (n.children && n.children.length) {
parser.STACK.push(n);
f(n.children);
parser.popNode(parser.STACK.pop());
} else n.children = void 0;
}
})(html);
}
nodes = html;
} else if (typeof html == 'object' && html.nodes) {
nodes = html.nodes;
console.warn('错误的 html 类型object 类型已废弃');
} else
return console.warn('错误的 html 类型:' + typeof html);
// #ifdef APP-PLUS
this.loadVideo = false;
// #endif
if (document) this.document = new document(this.nodes, 'nodes', this);
if (append) this.nodes = this.nodes.concat(nodes);
else this.nodes = nodes;
if (nodes.length && nodes[0].title && this.autosetTitle)
uni.setNavigationBarTitle({
title: nodes[0].title
})
this.$nextTick(() => {
this.imgList.length = 0;
this.videoContexts = [];
// #ifdef MP-TOUTIAO
setTimeout(() => {
// #endif
var f = (cs) => {
for (let i = 0, c; c = cs[i++];) {
if (c.$options.name == 'trees') {
for (var j = c.nodes.length, item; item = c.nodes[--j];) {
if (item.c) continue;
if (item.name == 'img') {
this.imgList.setItem(item.attrs.i, item.attrs.src);
// #ifndef MP-ALIPAY
if (!c.observer && !c.imgLoad && item.attrs.i != '0') {
if (this.lazyLoad && uni.createIntersectionObserver) {
c.observer = uni.createIntersectionObserver(c);
c.observer.relativeToViewport({
top: 900,
bottom: 900
}).observe('._img', () => {
c.imgLoad = true;
c.observer.disconnect();
})
} else
c.imgLoad = true;
}
// #endif
}
// #ifndef MP-ALIPAY
else if (item.name == 'video') {
var ctx = uni.createVideoContext(item.attrs.id, c);
ctx.id = item.attrs.id;
this.videoContexts.push(ctx);
}
// #endif
// #ifdef MP-BAIDU || MP-ALIPAY || APP-PLUS
if (item.attrs && item.attrs.id) {
this.anchors = this.anchors || [];
this.anchors.push({
id: item.attrs.id,
node: c
})
}
// #endif
}
}
if (c.$children.length)
f(c.$children)
}
}
f(this.$children);
// #ifdef MP-TOUTIAO
}, 200)
this.$emit('load');
// #endif
// #ifdef APP-PLUS
setTimeout(() => {
this.loadVideo = true;
}, 3000);
// #endif
})
// #endif
// #ifndef APP-PLUS-NVUE
var height;
clearInterval(this._timer);
this._timer = setInterval(() => {
// #ifdef H5
var res = [this.rtf.getBoundingClientRect()];
// #endif
// #ifndef H5
// #ifdef APP-PLUS
uni.createSelectorQuery().in(this)
// #endif
// #ifndef APP-PLUS
this.createSelectorQuery()
// #endif
.select('#top').boundingClientRect().exec(res => {
// #endif
this.width = res[0].width;
if (res[0].height == height) {
this.$emit('ready', res[0])
clearInterval(this._timer);
}
height = res[0].height;
// #ifndef H5
});
// #endif
}, 350)
if (this.showWithAnimation && !append) this.showAm = 'animation:show .5s';
// #endif
},
getText(ns = this.nodes) {
// #ifdef APP-PLUS-NVUE
return this._text;
// #endif
// #ifdef H5
return this.rtf.innerText;
// #endif
// #ifndef H5 || APP-PLUS-NVUE
var txt = '';
for (var i = 0, n; n = ns[i++];) {
if (n.type == 'text') txt += n.text.replace(/&nbsp;/g, '\u00A0').replace(/&lt;/g, '<').replace(/&gt;/g, '>')
.replace(/&amp;/g, '&');
else if (n.type == 'br') txt += '\n';
else {
// 块级标签前后加换行
var block = n.name == 'p' || n.name == 'div' || n.name == 'tr' || n.name == 'li' || (n.name[0] == 'h' && n.name[1] >
'0' && n.name[1] < '7');
if (block && txt && txt[txt.length - 1] != '\n') txt += '\n';
if (n.children) txt += this.getText(n.children);
if (block && txt[txt.length - 1] != '\n') txt += '\n';
else if (n.name == 'td' || n.name == 'th') txt += '\t';
}
}
return txt;
// #endif
},
navigateTo(obj) {
if (!this.useAnchor)
return obj.fail && obj.fail({
errMsg: 'Anchor is disabled'
})
// #ifdef APP-PLUS-NVUE
if (!obj.id)
dom.scrollToElement(this.$refs.web);
else
this.$refs.web.evalJs('var pos=document.getElementById("' + obj.id +
'");if(pos)post({action:"linkpress",href:"#",offset:pos.offsetTop})');
return obj.success && obj.success({
errMsg: 'pageScrollTo:ok'
});
// #endif
// #ifdef H5
if (!obj.id) {
window.scrollTo(0, this.rtf.offsetTop);
return obj.success && obj.success({
errMsg: 'pageScrollTo:ok'
});
}
var target = document.getElementById(obj.id);
if (!target) return obj.fail && obj.fail({
errMsg: 'Label not found'
});
obj.scrollTop = this.rtf.offsetTop + target.offsetTop;
uni.pageScrollTo(obj);
// #endif
// #ifndef H5
var Scroll = (selector, component) => {
uni.createSelectorQuery().in(component ? component : this).select(selector).boundingClientRect().selectViewport()
.scrollOffset()
.exec(res => {
if (!res || !res[0])
return obj.fail && obj.fail({
errMsg: 'Label not found'
});
obj.scrollTop = res[1].scrollTop + res[0].top;
uni.pageScrollTo(obj);
})
}
if (!obj.id) Scroll('#top');
else {
// #ifndef MP-BAIDU || MP-ALIPAY || APP-PLUS
Scroll('#top >>> #' + obj.id + ', #top >>> .' + obj.id);
// #endif
// #ifdef MP-BAIDU || MP-ALIPAY || APP-PLUS
for (var anchor of this.anchors)
if (anchor.id == obj.id)
Scroll('#' + obj.id + ', .' + obj.id, anchor.node);
// #endif
}
// #endif
},
getVideoContext(id) {
// #ifndef APP-PLUS-NVUE
if (!id) return this.videoContexts;
else
for (var i = this.videoContexts.length; i--;)
if (this.videoContexts[i].id == id) return this.videoContexts[i];
// #endif
},
// 预加载
preLoad(html, num) {
// #ifdef H5 || APP-PLUS-NVUE
if (html.constructor == Array)
html = this._Dom2Str(html);
var script = "var contain=document.createElement('div');contain.innerHTML='" + html.replace(/'/g, "\\'") +
"';for(var imgs=contain.querySelectorAll('img'),i=imgs.length-1;i>=" + num +
";i--)imgs[i].removeAttribute('src');";
// #endif
// #ifdef APP-PLUS-NVUE
this.$refs.web.evalJs(script);
// #endif
// #ifdef H5
eval(script);
// #endif
// #ifndef H5 || APP-PLUS-NVUE
if (typeof html == 'string') {
var id = hash(html);
html = new Parser(html, this).parse();
cache[id] = html;
}
var wait = [];
(function f(ns) {
for (var i = 0, n; n = ns[i++];) {
if (n.name == 'img' && n.attrs.src && !wait.includes(n.attrs.src))
wait.push(n.attrs.src);
f(n.children || []);
}
})(html);
if (num) wait = wait.slice(0, num);
this._wait = (this._wait || []).concat(wait);
if (!this.imgs) this.imgs = this._wait.splice(0, 15);
else if (this.imgs.length < 15)
this.imgs = this.imgs.concat(this._wait.splice(0, 15 - this.imgs.length));
// #endif
},
// #ifdef APP-PLUS-NVUE
_message(e) {
// 接收 web-view 消息
var data = e.detail.data[0];
if (data.action == 'load') {
this.$emit('load');
this._text = data.text;
} else if (data.action == 'getTitle') {
if (this.autosetTitle)
uni.setNavigationBarTitle({
title: data.title
})
} else if (data.action == 'getImgList') {
this.imgList.length = 0;
for (var i = data.imgList.length; i--;)
this.imgList.setItem(i, data.imgList[i]);
} else if (data.action == 'preview') {
var preview = true;
data.img.ignore = () => preview = false;
this.$emit('imgtap', data.img);
if (preview)
uni.previewImage({
current: data.img.i,
urls: this.imgList
})
} else if (data.action == 'linkpress') {
var jump = true,
href = data.href;
this.$emit('linkpress', {
href,
ignore: () => jump = false
})
if (jump && href) {
if (href[0] == '#') {
if (this.useAnchor)
dom.scrollToElement(this.$refs.web, {
offset: data.offset
})
} else if (href.includes('://'))
plus.runtime.openWeb(href);
else
uni.navigateTo({
url: href
})
}
} else if (data.action == 'error')
this.$emit('error', {
source: data.source,
target: data.target
})
else if (data.action == 'ready') {
this.height = data.height;
this.$nextTick(() => {
uni.createSelectorQuery().in(this).select('#top').boundingClientRect().exec(res => {
this.rect = res[0];
this.$emit('ready', res[0]);
})
})
}
},
// #endif
// #ifndef APP-PLUS-NVUE
// #ifndef H5
_load(e) {
if (this._wait.length)
this.$set(this.imgs, e.target.id, this._wait.shift());
},
// #endif
_tap(e) {
// #ifndef MP-BAIDU || MP-ALIPAY || APP-PLUS
if (this.gestureZoom && e.timeStamp - this._lastT < 300) {
var initY = e.touches[0].pageY - e.currentTarget.offsetTop;
if (this._zoom) {
this._scaleAm.translateX(0).scale(1).step();
uni.pageScrollTo({
scrollTop: (initY + this._initY) / 2 - e.touches[0].clientY,
duration: 400
})
} else {
var initX = e.touches[0].pageX - e.currentTarget.offsetLeft;
this._initY = initY;
this._scaleAm = uni.createAnimation({
transformOrigin: `${initX}px ${this._initY}px 0`,
timingFunction: 'ease-in-out'
});
// #ifdef MP-TOUTIAO
this._scaleAm.opacity(1);
// #endif
this._scaleAm.scale(2).step();
this._tMax = initX / 2;
this._tMin = (initX - this.width) / 2;
this._tX = 0;
}
this._zoom = !this._zoom;
this.scaleAm = this._scaleAm.export();
}
this._lastT = e.timeStamp;
// #endif
},
_touchstart(e) {
// #ifndef MP-BAIDU || MP-ALIPAY || APP-PLUS
if (e.touches.length == 1)
this._initX = this._lastX = e.touches[0].pageX;
// #endif
},
_touchmove(e) {
// #ifndef MP-BAIDU || MP-ALIPAY || APP-PLUS
var diff = e.touches[0].pageX - this._lastX;
if (this._zoom && e.touches.length == 1 && Math.abs(diff) > 20) {
this._lastX = e.touches[0].pageX;
if ((this._tX <= this._tMin && diff < 0) || (this._tX >= this._tMax && diff > 0))
return;
this._tX += (diff * Math.abs(this._lastX - this._initX) * 0.05);
if (this._tX < this._tMin) this._tX = this._tMin;
if (this._tX > this._tMax) this._tX = this._tMax;
this._scaleAm.translateX(this._tX).step();
this.scaleAm = this._scaleAm.export();
}
// #endif
}
// #endif
}
}
</script>
<style>
@keyframes show {
0% {
opacity: 0
}
100% {
opacity: 1;
}
}
/* #ifdef MP-WEIXIN */
:host {
display: block;
overflow: hidden;
-webkit-overflow-scrolling: touch;
}
/* #endif */
</style>

View File

@@ -0,0 +1,102 @@
/*
解析和匹配 Css 的选择器
githubhttps://github.com/jin-yufeng/Parser
docshttps://jin-yufeng.github.io/Parser
authorJinYufeng
update2020/03/15
*/
var cfg = require('./config.js');
class CssHandler {
constructor(tagStyle) {
var styles = Object.assign({}, cfg.userAgentStyles);
for (var item in tagStyle)
styles[item] = (styles[item] ? styles[item] + ';' : '') + tagStyle[item];
this.styles = styles;
}
getStyle = data => this.styles = new CssParser(data, this.styles).parse();
match(name, attrs) {
var tmp, matched = (tmp = this.styles[name]) ? tmp + ';' : '';
if (attrs.class) {
var items = attrs.class.split(' ');
for (var i = 0, item; item = items[i]; i++)
if (tmp = this.styles['.' + item])
matched += tmp + ';';
}
if (tmp = this.styles['#' + attrs.id])
matched += tmp + ';';
return matched;
}
}
module.exports = CssHandler;
class CssParser {
constructor(data, init) {
this.data = data;
this.floor = 0;
this.i = 0;
this.list = [];
this.res = init;
this.state = this.Space;
}
parse() {
for (var c; c = this.data[this.i]; this.i++)
this.state(c);
return this.res;
}
section = () => this.data.substring(this.start, this.i);
isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
// 状态机
Space(c) {
if (c == '.' || c == '#' || this.isLetter(c)) {
this.start = this.i;
this.state = this.Name;
} else if (c == '/' && this.data[this.i + 1] == '*')
this.Comment();
else if (!cfg.blankChar[c] && c != ';')
this.state = this.Ignore;
}
Comment() {
this.i = this.data.indexOf('*/', this.i) + 1;
if (!this.i) this.i = this.data.length;
this.state = this.Space;
}
Ignore(c) {
if (c == '{') this.floor++;
else if (c == '}' && !--this.floor) this.state = this.Space;
}
Name(c) {
if (cfg.blankChar[c]) {
this.list.push(this.section());
this.state = this.NameSpace;
} else if (c == '{') {
this.list.push(this.section());
this.Content();
} else if (c == ',') {
this.list.push(this.section());
this.Comma();
} else if (!this.isLetter(c) && (c < '0' || c > '9') && c != '-' && c != '_')
this.state = this.Ignore;
}
NameSpace(c) {
if (c == '{') this.Content();
else if (c == ',') this.Comma();
else if (!cfg.blankChar[c]) this.state = this.Ignore;
}
Comma() {
while (cfg.blankChar[this.data[++this.i]]);
if (this.data[this.i] == '{') this.Content();
else {
this.start = this.i--;
this.state = this.Name;
}
}
Content() {
this.start = ++this.i;
if ((this.i = this.data.indexOf('}', this.i)) == -1) this.i = this.data.length;
var content = this.section();
for (var i = 0, item; item = this.list[i++];)
if (this.res[item]) this.res[item] += ';' + content;
else this.res[item] = content;
this.list = [];
this.state = this.Space;
}
}

View File

@@ -0,0 +1,577 @@
/*
将 html 解析为适用于小程序 rich-text 的 DOM 结构
githubhttps://github.com/jin-yufeng/Parser
docshttps://jin-yufeng.github.io/Parser
authorJinYufeng
update2020/04/13
*/
var cfg = require('./config.js'),
blankChar = cfg.blankChar,
CssHandler = require('./CssHandler.js'),
{
screenWidth,
system
} = wx.getSystemInfoSync();
// #ifdef MP-BAIDU || MP-ALIPAY || MP-TOUTIAO
var entities = {
lt: '<',
gt: '>',
amp: '&',
quot: '"',
apos: "'",
nbsp: '\xA0',
ensp: '\u2002',
emsp: '\u2003',
ndash: '',
mdash: '—',
middot: '·',
lsquo: '',
rsquo: '',
ldquo: '“',
rdquo: '”',
bull: '•',
hellip: '…',
permil: '‰',
copy: '©',
reg: '®',
trade: '™',
times: '×',
divide: '÷',
cent: '¢',
pound: '£',
yen: '¥',
euro: '€',
sect: '§'
};
// #endif
var emoji; // emoji 补丁包 https://jin-yufeng.github.io/Parser/#/instructions?id=emoji
class MpHtmlParser {
constructor(data, options = {}) {
this.attrs = {};
this.compress = options.compress;
this.CssHandler = new CssHandler(options.tagStyle, screenWidth);
this.data = data;
this.domain = options.domain;
this.DOM = [];
this.i = this.start = this.audioNum = this.imgNum = this.videoNum = 0;
this.protocol = this.domain && this.domain.includes('://') ? this.domain.split('://')[0] : '';
this.state = this.Text;
this.STACK = [];
this.useAnchor = options.useAnchor;
this.xml = options.xml;
}
parse() {
if (emoji) this.data = emoji.parseEmoji(this.data);
for (var c; c = this.data[this.i]; this.i++)
this.state(c);
if (this.state == this.Text) this.setText();
while (this.STACK.length) this.popNode(this.STACK.pop());
// #ifdef MP-BAIDU || MP-TOUTIAO
// 将顶层标签的一些样式提取出来给 rich-text
(function f(ns) {
for (var i = ns.length, n; n = ns[--i];) {
if (n.type == 'text') continue;
if (!n.c) {
var style = n.attrs.style;
if (style) {
var j, k, res;
if ((j = style.indexOf('display')) != -1)
res = style.substring(j, (k = style.indexOf(';', j)) == -1 ? style.length : k);
if ((j = style.indexOf('float')) != -1)
res += ';' + style.substring(j, (k = style.indexOf(';', j)) == -1 ? style.length : k);
n.attrs.contain = res;
}
} else f(n.children);
}
})(this.DOM);
// #endif
if (this.DOM.length) {
this.DOM[0].PoweredBy = 'Parser';
if (this.title) this.DOM[0].title = this.title;
}
return this.DOM;
}
// 设置属性
setAttr() {
var name = this.getName(this.attrName);
if (cfg.trustAttrs[name]) {
if (!this.attrVal) {
if (cfg.boolAttrs[name]) this.attrs[name] = 'T';
} else if (name == 'src') this.attrs[name] = this.getUrl(this.attrVal.replace(/&amp;/g, '&'));
else this.attrs[name] = this.attrVal;
}
this.attrVal = '';
while (blankChar[this.data[this.i]]) this.i++;
if (this.isClose()) this.setNode();
else {
this.start = this.i;
this.state = this.AttrName;
}
}
// 设置文本节点
setText() {
var back, text = this.section();
if (!text) return;
text = (cfg.onText && cfg.onText(text, () => back = true)) || text;
if (back) {
this.data = this.data.substr(0, this.start) + text + this.data.substr(this.i);
let j = this.start + text.length;
for (this.i = this.start; this.i < j; this.i++) this.state(this.data[this.i]);
return;
}
if (!this.pre) {
// 合并空白符
var tmp = [];
for (let i = text.length, c; c = text[--i];)
if (!blankChar[c] || (!blankChar[tmp[0]] && (c = ' '))) tmp.unshift(c);
text = tmp.join('');
if (text == ' ') return;
}
// 处理实体
var siblings = this.siblings(),
i = -1,
j, en;
while (1) {
if ((i = text.indexOf('&', i + 1)) == -1) break;
if ((j = text.indexOf(';', i + 2)) == -1) break;
if (text[i + 1] == '#') {
en = parseInt((text[i + 2] == 'x' ? '0' : '') + text.substring(i + 2, j));
if (!isNaN(en)) text = text.substr(0, i) + String.fromCharCode(en) + text.substring(j + 1);
} else {
en = text.substring(i + 1, j);
// #ifdef MP-WEIXIN || MP-QQ || APP-PLUS
if (en == 'nbsp') text = text.substr(0, i) + '\xA0' + text.substr(j + 1); // 解决 &nbsp; 失效
else if (en != 'lt' && en != 'gt' && en != 'amp' && en != 'ensp' && en != 'emsp' && en != 'quot' && en != 'apos') {
i && siblings.push({
type: 'text',
text: text.substr(0, i)
})
siblings.push({
type: 'text',
text: `&${en};`,
en: 1
})
text = text.substr(j + 1);
i = -1;
}
// #endif
// #ifdef MP-BAIDU || MP-ALIPAY || MP-TOUTIAO
if (entities[en]) text = text.substr(0, i) + entities[en] + text.substr(j + 1);
// #endif
}
}
text && siblings.push({
type: 'text',
text
})
}
// 设置元素节点
setNode() {
var node = {
name: this.tagName.toLowerCase(),
attrs: this.attrs
},
close = cfg.selfClosingTags[node.name] || (this.xml && this.data[this.i] == '/');
this.attrs = {};
if (!cfg.ignoreTags[node.name]) {
this.matchAttr(node);
if (!close) {
node.children = [];
if (node.name == 'pre' && cfg.highlight) {
this.remove(node);
this.pre = node.pre = true;
}
this.siblings().push(node);
this.STACK.push(node);
} else if (!cfg.filter || cfg.filter(node, this) != false)
this.siblings().push(node);
} else {
if (!close) this.remove(node);
else if (node.name == 'source') {
var parent = this.STACK[this.STACK.length - 1],
attrs = node.attrs;
if (parent && attrs.src)
if (parent.name == 'video' || parent.name == 'audio')
parent.attrs.source.push(attrs.src);
else {
var i, media = attrs.media;
if (parent.name == 'picture' && !parent.attrs.src && !(attrs.src.indexOf('.webp') && system.includes('iOS')) &&
(!media || (media.includes('px') &&
(((i = media.indexOf('min-width')) != -1 && (i = media.indexOf(':', i + 8)) != -1 && screenWidth > parseInt(
media.substr(i + 1))) ||
((i = media.indexOf('max-width')) != -1 && (i = media.indexOf(':', i + 8)) != -1 && screenWidth < parseInt(
media.substr(i + 1)))))))
parent.attrs.src = attrs.src;
}
} else if (node.name == 'base' && !this.domain) this.domain = node.attrs.href;
}
if (this.data[this.i] == '/') this.i++;
this.start = this.i + 1;
this.state = this.Text;
}
// 移除标签
remove(node) {
var name = node.name,
j = this.i;
while (1) {
if ((this.i = this.data.indexOf('</', this.i + 1)) == -1) {
if (name == 'pre' || name == 'svg') this.i = j;
else this.i = this.data.length;
return;
}
this.start = (this.i += 2);
while (!blankChar[this.data[this.i]] && !this.isClose()) this.i++;
if (this.getName(this.section()) == name) {
// 代码块高亮
if (name == 'pre') {
this.data = this.data.substr(0, j + 1) + cfg.highlight(this.data.substring(j + 1, this.i - 5), node.attrs) +
this.data.substr(this.i - 5);
return this.i = j;
} else if (name == 'style')
this.CssHandler.getStyle(this.data.substring(j + 1, this.i - 7));
else if (name == 'title')
this.title = this.data.substring(j + 1, this.i - 7);
if ((this.i = this.data.indexOf('>', this.i)) == -1) this.i = this.data.length;
// 处理 svg
if (name == 'svg') {
var src = this.data.substring(j, this.i + 1);
if (!node.attrs.xmlns) src = ' xmlns="http://www.w3.org/2000/svg"' + src;
var i = j;
while (this.data[j] != '<') j--;
src = this.data.substring(j, i) + src;
var parent = this.STACK[this.STACK.length - 1];
if (node.attrs.width == '100%' && parent && (parent.attrs.style || '').includes('inline'))
parent.attrs.style = 'width:300px;max-width:100%;' + parent.attrs.style;
this.siblings().push({
name: 'img',
attrs: {
src: 'data:image/svg+xml;utf8,' + src.replace(/#/g, '%23'),
ignore: 'T'
}
})
}
return;
}
}
}
// 处理属性
matchAttr(node) {
var attrs = node.attrs,
style = this.CssHandler.match(node.name, attrs, node) + (attrs.style || ''),
styleObj = {};
if (attrs.id) {
if (this.compress & 1) attrs.id = void 0;
else if (this.useAnchor) this.bubble();
}
if ((this.compress & 2) && attrs.class) attrs.class = void 0;
switch (node.name) {
case 'img':
if (attrs['data-src']) {
attrs.src = attrs.src || attrs['data-src'];
attrs['data-src'] = void 0;
}
if (attrs.src && !attrs.ignore) {
if (this.bubble()) attrs.i = (this.imgNum++).toString();
else attrs.ignore = 'T';
}
break;
case 'a':
case 'ad':
// #ifdef APP-PLUS
case 'iframe':
case 'embed':
// #endif
this.bubble();
break;
case 'font':
if (attrs.color) {
styleObj['color'] = attrs.color;
attrs.color = void 0;
}
if (attrs.face) {
styleObj['font-family'] = attrs.face;
attrs.face = void 0;
}
if (attrs.size) {
var size = parseInt(attrs.size);
if (size < 1) size = 1;
else if (size > 7) size = 7;
var map = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'];
styleObj['font-size'] = map[size - 1];
attrs.size = void 0;
}
break;
case 'video':
case 'audio':
if (!attrs.id) attrs.id = node.name + (++this[`${node.name}Num`]);
else this[`${node.name}Num`]++;
if (node.name == 'video') {
if (attrs.width) {
style = `width:${parseFloat(attrs.width) + (attrs.width.includes('%') ? '%' : 'px')};${style}`;
attrs.width = void 0;
}
if (attrs.height) {
style = `height:${parseFloat(attrs.height) + (attrs.height.includes('%') ? '%' : 'px')};${style}`;
attrs.height = void 0;
}
if (this.videoNum > 3) node.lazyLoad = true;
}
attrs.source = [];
if (attrs.src) attrs.source.push(attrs.src);
if (!attrs.controls && !attrs.autoplay)
console.warn(`存在没有 controls 属性的 ${node.name} 标签,可能导致无法播放`, node);
this.bubble();
break;
case 'td':
case 'th':
if (attrs.colspan || attrs.rowspan)
for (var k = this.STACK.length, item; item = this.STACK[--k];)
if (item.name == 'table') {
item.c = void 0;
break;
}
}
if (attrs.align) {
styleObj['text-align'] = attrs.align;
attrs.align = void 0;
}
// 压缩 style
var styles = style.replace(/&quot;/g, '"').replace(/&amp;/g, '&').split(';');
style = '';
for (var i = 0, len = styles.length; i < len; i++) {
var info = styles[i].split(':');
if (info.length < 2) continue;
let key = info[0].trim().toLowerCase(),
value = info.slice(1).join(':').trim();
if (value.includes('-webkit') || value.includes('-moz') || value.includes('-ms') || value.includes('-o') || value
.includes(
'safe'))
style += `;${key}:${value}`;
else if (!styleObj[key] || value.includes('import') || !styleObj[key].includes('import'))
styleObj[key] = value;
}
if (node.name == 'img' && parseInt(styleObj.width || attrs.width) > screenWidth)
styleObj.height = 'auto';
for (var key in styleObj) {
var value = styleObj[key];
if (key.includes('flex') || key == 'order' || key == 'self-align') node.c = 1;
// 填充链接
if (value.includes('url')) {
var j = value.indexOf('(');
if (j++ != -1) {
while (value[j] == '"' || value[j] == "'" || blankChar[value[j]]) j++;
value = value.substr(0, j) + this.getUrl(value.substr(j));
}
}
// 转换 rpx
else if (value.includes('rpx'))
value = value.replace(/[0-9.]+\s*rpx/g, $ => parseFloat($) * screenWidth / 750 + 'px');
else if (key == 'white-space' && value.includes('pre'))
this.pre = node.pre = true;
style += `;${key}:${value}`;
}
style = style.substr(1);
if (style) attrs.style = style;
}
// 节点出栈处理
popNode(node) {
// 空白符处理
if (node.pre) {
node.pre = this.pre = void 0;
for (let i = this.STACK.length; i--;)
if (this.STACK[i].pre)
this.pre = true;
}
if (node.name == 'head' || (cfg.filter && cfg.filter(node, this) == false))
return this.siblings().pop();
var attrs = node.attrs;
// 替换一些标签名
if (node.name == 'picture') {
node.name = 'img';
if (!attrs.src && (node.children[0] || '').name == 'img')
attrs.src = node.children[0].attrs.src;
if (attrs.src && !attrs.ignore)
attrs.i = (this.imgNum++).toString();
return node.children = void 0;
}
if (cfg.blockTags[node.name]) node.name = 'div';
else if (!cfg.trustTags[node.name]) node.name = 'span';
// 处理列表
if (node.c) {
if (node.name == 'ul') {
var floor = 1;
for (let i = this.STACK.length; i--;)
if (this.STACK[i].name == 'ul') floor++;
if (floor != 1)
for (let i = node.children.length; i--;)
node.children[i].floor = floor;
} else if (node.name == 'ol') {
for (let i = 0, num = 1, child; child = node.children[i++];)
if (child.name == 'li') {
child.type = 'ol';
child.num = ((num, type) => {
if (type == 'a') return String.fromCharCode(97 + (num - 1) % 26);
if (type == 'A') return String.fromCharCode(65 + (num - 1) % 26);
if (type == 'i' || type == 'I') {
num = (num - 1) % 99 + 1;
var one = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'],
ten = ['X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'],
res = (ten[Math.floor(num / 10) - 1] || '') + (one[num % 10 - 1] || '');
if (type == 'i') return res.toLowerCase();
return res;
}
return num;
})(num++, attrs.type) + '.';
}
}
}
// 处理表格的边框
if (node.name == 'table') {
var padding = attrs.cellpadding,
spacing = attrs.cellspacing,
border = attrs.border;
if (node.c) {
this.bubble();
if (!padding) padding = 2;
if (!spacing) spacing = 2;
}
if (border) attrs.style = `border:${border}px solid gray;${attrs.style || ''}`;
if (spacing) attrs.style = `border-spacing:${spacing}px;${attrs.style || ''}`;
if (border || padding)
(function f(ns) {
for (var i = 0, n; n = ns[i]; i++) {
if (n.name == 'th' || n.name == 'td') {
if (border) n.attrs.style = `border:${border}px solid gray;${n.attrs.style}`;
if (padding) n.attrs.style = `padding:${padding}px;${n.attrs.style}`;
} else f(n.children || []);
}
})(node.children)
}
this.CssHandler.pop && this.CssHandler.pop(node);
// 自动压缩
if (node.name == 'div' && !Object.keys(attrs).length) {
var siblings = this.siblings();
if (node.children.length == 1 && node.children[0].name == 'div')
siblings[siblings.length - 1] = node.children[0];
}
}
// 工具函数
bubble() {
for (var i = this.STACK.length, item; item = this.STACK[--i];) {
if (cfg.richOnlyTags[item.name]) {
if (item.name == 'table' && !Object.hasOwnProperty.call(item, 'c')) item.c = 1;
return false;
}
item.c = 1;
}
return true;
}
getName = val => this.xml ? val : val.toLowerCase();
getUrl(url) {
if (url[0] == '/') {
if (url[1] == '/') url = this.protocol + ':' + url;
else if (this.domain) url = this.domain + url;
} else if (this.domain && url.indexOf('data:') != 0 && !url.includes('://'))
url = this.domain + '/' + url;
return url;
}
isClose = () => this.data[this.i] == '>' || (this.data[this.i] == '/' && this.data[this.i + 1] == '>');
section = () => this.data.substring(this.start, this.i);
siblings = () => this.STACK.length ? this.STACK[this.STACK.length - 1].children : this.DOM;
// 状态机
Text(c) {
if (c == '<') {
var next = this.data[this.i + 1],
isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
if (isLetter(next)) {
this.setText();
this.start = this.i + 1;
this.state = this.TagName;
} else if (next == '/') {
this.setText();
if (isLetter(this.data[++this.i + 1])) {
this.start = this.i + 1;
this.state = this.EndTag;
} else
this.Comment();
} else if (next == '!') {
this.setText();
this.Comment();
}
}
}
Comment() {
var key;
if (this.data.substring(this.i + 2, this.i + 4) == '--') key = '-->';
else if (this.data.substring(this.i + 2, this.i + 9) == '[CDATA[') key = ']]>';
else key = '>';
if ((this.i = this.data.indexOf(key, this.i + 2)) == -1) this.i = this.data.length;
else this.i += key.length - 1;
this.start = this.i + 1;
this.state = this.Text;
}
TagName(c) {
if (blankChar[c]) {
this.tagName = this.section();
while (blankChar[this.data[this.i]]) this.i++;
if (this.isClose()) this.setNode();
else {
this.start = this.i;
this.state = this.AttrName;
}
} else if (this.isClose()) {
this.tagName = this.section();
this.setNode();
}
}
AttrName(c) {
var blank = blankChar[c];
if (blank) {
this.attrName = this.section();
c = this.data[this.i];
}
if (c == '=') {
if (!blank) this.attrName = this.section();
while (blankChar[this.data[++this.i]]);
this.start = this.i--;
this.state = this.AttrValue;
} else if (blank) this.setAttr();
else if (this.isClose()) {
this.attrName = this.section();
this.setAttr();
}
}
AttrValue(c) {
if (c == '"' || c == "'") {
this.start++;
if ((this.i = this.data.indexOf(c, this.i + 1)) == -1) return this.i = this.data.length;
this.attrVal = this.section();
this.i++;
} else {
for (; !blankChar[this.data[this.i]] && !this.isClose(); this.i++);
this.attrVal = this.section();
}
this.setAttr();
}
EndTag(c) {
if (blankChar[c] || c == '>' || c == '/') {
var name = this.getName(this.section());
for (var i = this.STACK.length; i--;)
if (this.STACK[i].name == name) break;
if (i != -1) {
var node;
while ((node = this.STACK.pop()).name != name);
this.popNode(node);
} else if (name == 'p' || name == 'br')
this.siblings().push({
name,
attrs: {}
});
this.i = this.data.indexOf('>', this.i);
this.start = this.i + 1;
if (this.i == -1) this.i = this.data.length;
else this.state = this.Text;
}
}
}
module.exports = MpHtmlParser;

View File

@@ -0,0 +1,80 @@
/* 配置文件 */
// #ifdef MP-WEIXIN
const canIUse = wx.canIUse('editor'); // 高基础库标识,用于兼容
// #endif
module.exports = {
// 过滤器函数
filter: null,
// 代码高亮函数
highlight: null,
// 文本处理函数
onText: null,
blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'),
// 块级标签,将被转为 div
blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,section' + (
// #ifdef MP-WEIXIN
canIUse ? '' :
// #endif
',pre')),
// 将被移除的标签
ignoreTags: makeMap(
'area,base,basefont,canvas,command,frame,input,isindex,keygen,link,map,meta,param,script,source,style,svg,textarea,title,track,use,wbr'
// #ifdef MP-WEIXIN
+ (canIUse ? ',rp' : '')
// #endif
// #ifndef APP-PLUS
+ ',embed,iframe'
// #endif
),
// 只能被 rich-text 显示的标签
richOnlyTags: makeMap('a,colgroup,fieldset,legend,picture,table'
// #ifdef MP-WEIXIN
+ (canIUse ? ',bdi,bdo,caption,rt,ruby' : '')
// #endif
),
// 自闭合的标签
selfClosingTags: makeMap(
'area,base,basefont,br,col,circle,ellipse,embed,frame,hr,img,input,isindex,keygen,line,link,meta,param,path,polygon,rect,source,track,use,wbr'
),
// 信任的属性
trustAttrs: makeMap(
'align,alt,app-id,author,autoplay,border,cellpadding,cellspacing,class,color,colspan,controls,data-src,dir,face,height,href,id,ignore,loop,media,muted,name,path,poster,rowspan,size,span,src,start,style,type,unit-id,width,xmlns'
),
// bool 型的属性
boolAttrs: makeMap('autoplay,controls,ignore,loop,muted'),
// 信任的标签
trustTags: makeMap(
'a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video'
// #ifdef MP-WEIXIN
+ (canIUse ? ',bdi,bdo,caption,pre,rt,ruby' : '')
// #endif
// #ifdef APP-PLUS
+ ',embed,iframe'
// #endif
),
// 默认的标签样式
userAgentStyles: {
address: 'font-style:italic',
big: 'display:inline;font-size:1.2em',
blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px',
caption: 'display:table-caption;text-align:center',
center: 'text-align:center',
cite: 'font-style:italic',
dd: 'margin-left:40px',
img: 'max-width:100%',
mark: 'background-color:yellow',
picture: 'max-width:100%',
pre: 'font-family:monospace;white-space:pre;overflow:scroll',
s: 'text-decoration:line-through',
small: 'display:inline;font-size:0.8em',
u: 'text-decoration:underline'
}
}
function makeMap(maprichee55text9oppplugin) {
var map = {},
list = maprichee55text9oppplugin.split(',');
for (var i = list.length; i--;)
map[list[i]] = true;
return map;
}

View File

@@ -0,0 +1,35 @@
var inlineTags = {
abbr: 1,
b: 1,
big: 1,
code: 1,
del: 1,
em: 1,
i: 1,
ins: 1,
label: 1,
q: 1,
small: 1,
span: 1,
strong: 1
}
export default {
// 从顶层标签的样式中取出一些给 rich-text
getStyle: function(style) {
if (style) {
var i, j, res = '';
if ((i = style.indexOf('display')) != -1)
res = style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j);
if ((i = style.indexOf('float')) != -1)
res += ';' + style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j);
return res;
}
},
getNode: function(item) {
return [item];
},
// 是否通过 rich-text 显示
useRichText: function(item) {
return !item.c && !inlineTags[item.name] && (item.attrs.style || '').indexOf('display:inline') == -1;
}
}

View File

@@ -0,0 +1,44 @@
var inlineTags = {
abbr: 1,
b: 1,
big: 1,
code: 1,
del: 1,
em: 1,
i: 1,
ins: 1,
label: 1,
q: 1,
small: 1,
span: 1,
strong: 1
}
module.exports = {
// 从顶层标签的样式中取出一些给 rich-text
getStyle: function(style) {
if (style) {
var i, j, res = '';
if ((i = style.indexOf('display')) != -1)
res = style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j);
if ((i = style.indexOf('float')) != -1)
res += ';' + style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j);
return res;
}
},
// 处理懒加载
getNode: function(item, imgLoad) {
if (!imgLoad && item.attrs.i != '0') {
var img = {
name: 'img',
attrs: JSON.parse(JSON.stringify(item.attrs))
}
delete img.attrs.src;
img.attrs.style += ';width:20px;height:20px';
return [img];
} else return [item];
},
// 是否通过 rich-text 显示
useRichText: function(item) {
return !item.c && !inlineTags[item.name] && (item.attrs.style || '').indexOf('display:inline') == -1;
}
}

View File

@@ -0,0 +1,476 @@
<!--
trees 递归显示组件
githubhttps://github.com/jin-yufeng/Parser
docshttps://jin-yufeng.github.io/Parser
插件市场https://ext.dcloud.net.cn/plugin?id=805
authorJinYufeng
update2020/04/13
-->
<template>
<view class="interlayer">
<block v-for="(n, index) in nodes" v-bind:key="index">
<!--图片-->
<!--#ifdef MP-WEIXIN || MP-QQ || MP-ALIPAY || APP-PLUS-->
<rich-text v-if="n.name=='img'" :id="n.attrs.id" class="_img" :style="''+handler.getStyle(n.attrs.style)" :nodes="handler.getNode(n,!lazyLoad||imgLoad)"
:data-attrs="n.attrs" @tap="imgtap" @longpress="imglongtap" />
<!--#endif-->
<!--#ifdef MP-BAIDU || MP-TOUTIAO-->
<rich-text v-if="n.name=='img'" :id="n.attrs.id" class="_img" :style="n.attrs.contain" :nodes='[n]' :data-attrs="n.attrs"
@tap="imgtap" @longpress="imglongtap" />
<!--#endif-->
<!--文本-->
<!--#ifdef MP-WEIXIN || MP-QQ || APP-PLUS-->
<rich-text v-else-if="n.decode" class="_entity" :nodes="[n]"></rich-text>
<!--#endif-->
<text v-else-if="n.type=='text'" decode>{{n.text}}</text>
<text v-else-if="n.name=='br'">\n</text>
<!--视频-->
<view v-else-if="n.name=='video'">
<view v-if="(!loadVideo||n.lazyLoad)&&!(controls[n.attrs.id]&&controls[n.attrs.id].play)" :id="n.attrs.id" :class="'_video '+(n.attrs.class||'')"
:style="n.attrs.style" @tap="_loadVideo" />
<video v-else :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :autoplay="n.attrs.autoplay||(controls[n.attrs.id]&&controls[n.attrs.id].play)"
:controls="n.attrs.controls" :loop="n.attrs.loop" :muted="n.attrs.muted" :poster="n.attrs.poster" :src="n.attrs.source[(controls[n.attrs.id]&&controls[n.attrs.id].index)||0]"
:unit-id="n.attrs['unit-id']" :data-id="n.attrs.id" data-from="video" data-source="source" @error="error" @play="play" />
</view>
<!--音频-->
<audio v-else-if="n.name=='audio'" :class="n.attrs.class" :style="n.attrs.style" :author="n.attrs.author" :autoplay="n.attrs.autoplay"
:controls="n.attrs.controls" :loop="n.attrs.loop" :name="n.attrs.name" :poster="n.attrs.poster" :src="n.attrs.source[(controls[n.attrs.id]&&controls[n.attrs.id].index)||0]"
:data-id="n.attrs.id" data-from="audio" data-source="source" @error="error" @play="play" />
<!--链接-->
<view v-else-if="n.name=='a'" :class="'_a '+(n.attrs.class||'')" hover-class="_hover" :style="n.attrs.style"
:data-attrs="n.attrs" @tap="linkpress">
<trees class="_span" :nodes="n.children" />
</view>
<!--广告按需打开注释-->
<!--#ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO-->
<!--<ad v-else-if="n.name=='ad'" :class="n.attrs.class" :style="n.attrs.style" :unit-id="n.attrs['unit-id']"
data-from="ad" @error="error" />-->
<!--#endif-->
<!--#ifdef MP-BAIDU-->
<!--<ad v-else-if="n.name=='ad'" :class="n.attrs.class" :style="n.attrs.style" :appid="n.attrs.appid"
:apid="n.attrs.apid" :type="n.attrs.type" data-from="ad" @error="error" />-->
<!--#endif-->
<!--#ifdef APP-PLUS-->
<!--<ad v-else-if="n.name=='ad'" :class="n.attrs.class" :style="n.attrs.style" :adpid="n.attrs.adpid"
data-from="ad" @error="error" />-->
<!--#endif-->
<!--列表-->
<view v-else-if="n.name=='li'" :id="n.attrs.id" :class="n.attrs.class" :style="(n.attrs.style||'')+';display:flex'">
<view v-if="n.type=='ol'" class="_ol-bef">{{n.num}}</view>
<view v-else class="_ul-bef">
<view v-if="n.floor%3==0" class="_ul-p1"></view>
<view v-else-if="n.floor%3==2" class="_ul-p2" />
<view v-else class="_ul-p1" style="border-radius:50%"></view>
</view>
<!--#ifdef MP-ALIPAY-->
<view class="_li">
<trees :nodes="n.children" />
</view>
<!--#endif-->
<!--#ifndef MP-ALIPAY-->
<trees class="_li" :nodes="n.children" :lazyLoad="lazyLoad" :loadVideo="loadVideo" />
<!--#endif-->
</view>
<!--表格-->
<view v-else-if="n.name=='table'&&n.c" :id="n.attrs.id" :class="n.attrs.class" :style="(n.attrs.style||'')+';display:table'">
<view v-for="(tbody, i) in n.children" v-bind:key="i" :class="tbody.attrs.class" :style="(tbody.attrs.style||'')+(tbody.name[0]=='t'?';display:table-'+(tbody.name=='tr'?'row':'row-group'):'')">
<view v-for="(tr, j) in tbody.children" v-bind:key="j" :class="tr.attrs.class" :style="(tr.attrs.style||'')+(tr.name[0]=='t'?';display:table-'+(tr.name=='tr'?'row':'cell'):'')">
<trees v-if="tr.name=='td'" :nodes="tr.children" :lazyLoad="lazyLoad" :loadVideo="loadVideo" />
<block v-else>
<!--#ifdef MP-ALIPAY-->
<view v-for="(td, k) in tr.children" v-bind:key="k" :class="td.attrs.class" :style="(td.attrs.style||'')+(td.name[0]=='t'?';display:table-'+(td.name=='tr'?'row':'cell'):'')">
<trees :nodes="td.children" />
</view>
<!--#endif-->
<!--#ifndef MP-ALIPAY-->
<trees v-for="(td, k) in tr.children" v-bind:key="k" :class="td.attrs.class" :style="(td.attrs.style||'')+(td.name[0]=='t'?';display:table-'+(td.name=='tr'?'row':'cell'):'')"
:nodes="td.children" :lazyLoad="lazyLoad" :loadVideo="loadVideo" />
<!--#endif-->
</block>
</view>
</view>
</view>
<!--#ifdef APP-PLUS-->
<iframe v-else-if="n.name=='iframe'" :style="n.attrs.style" :allowfullscreen="n.attrs.allowfullscreen" :frameborder="n.attrs.frameborder"
:width="n.attrs.width" :height="n.attrs.height" :src="n.attrs.src" />
<embed v-else-if="n.name=='embed'" :style="n.attrs.style" :width="n.attrs.width" :height="n.attrs.height" :src="n.attrs.src" />
<!--#endif-->
<!--富文本-->
<!--#ifdef MP-WEIXIN || MP-QQ || MP-ALIPAY || APP-PLUS-->
<rich-text v-else-if="handler.useRichText(n)" :id="n.attrs.id" :class="'_p __'+n.name" :nodes="[n]" />
<!--#endif-->
<!--#ifdef MP-BAIDU || MP-TOUTIAO-->
<rich-text v-else-if="!(n.c||n.continue)" :id="n.attrs.id" :class="_p" :style="n.attrs.contain" :nodes="[n]" />
<!--#endif-->
<!--#ifdef MP-ALIPAY-->
<view v-else :id="n.attrs.id" :class="'_'+n.name+' '+(n.attrs.class||'')" :style="n.attrs.style">
<trees :nodes="n.children" />
</view>
<!--#endif-->
<!--#ifndef MP-ALIPAY-->
<trees v-else :class="(n.attrs.id||'')+' _'+n.name+' '+(n.attrs.class||'')" :style="n.attrs.style" :nodes="n.children"
:lazyLoad="lazyLoad" :loadVideo="loadVideo" />
<!--#endif-->
</block>
</view>
</template>
<script module="handler" lang="wxs" src="./handler.wxs"></script>
<script module="handler" lang="sjs" src="./handler.sjs"></script>
<script>
global.Parser = {};
import trees from './trees'
export default {
components: {
trees
},
name: 'trees',
data() {
return {
controls: {},
// #ifdef MP-WEIXIN || MP-QQ || APP-PLUS
imgLoad: false,
// #endif
// #ifndef APP-PLUS
loadVideo: true
// #endif
}
},
props: {
nodes: Array,
// #ifdef MP-WEIXIN || MP-QQ || H5 || APP-PLUS
lazyLoad: Boolean,
// #endif
// #ifdef APP-PLUS
loadVideo: Boolean
// #endif
},
mounted() {
// 获取顶层组件
this.top = this.$parent;
while (this.top.$options.name != 'parser') {
if (this.top.top) {
this.top = this.top.top;
break;
}
this.top = this.top.$parent;
}
},
// #ifdef MP-WEIXIN || MP-QQ || APP-PLUS
beforeDestroy() {
if (this.observer)
this.observer.disconnect();
},
// #endif
methods: {
// #ifndef MP-ALIPAY
play(e) {
if (this.top.videoContexts.length > 1 && this.top.autopause)
for (var i = this.top.videoContexts.length; i--;)
if (this.top.videoContexts[i].id != e.currentTarget.dataset.id)
this.top.videoContexts[i].pause();
},
// #endif
imgtap(e) {
var attrs = e.currentTarget.dataset.attrs;
if (!attrs.ignore) {
var preview = true, data = {
id: e.target.id,
src: attrs.src,
ignore: () => preview = false
};
global.Parser.onImgtap && global.Parser.onImgtap(data);
this.top.$emit('imgtap', data);
if (preview) {
var urls = this.top.imgList,
current = urls[attrs.i] ? parseInt(attrs.i) : (urls = [attrs.src], 0);
uni.previewImage({
current,
urls
})
}
}
},
imglongtap(e) {
var attrs = e.item.dataset.attrs;
if (!attrs.ignore)
this.top.$emit('imglongtap', {
id: e.target.id,
src: attrs.src
})
},
linkpress(e) {
var jump = true,
attrs = e.currentTarget.dataset.attrs;
attrs.ignore = () => jump = false;
global.Parser.onLinkpress && global.Parser.onLinkpress(attrs);
this.top.$emit('linkpress', attrs);
if (jump) {
// #ifdef MP
if (attrs['app-id']) {
return uni.navigateToMiniProgram({
appId: attrs['app-id'],
path: attrs.path
})
}
// #endif
if (attrs.href) {
if (attrs.href[0] == '#') {
if (this.top.useAnchor)
this.top.navigateTo({
id: attrs.href.substring(1)
})
} else if (attrs.href.indexOf('http') == 0 || attrs.href.indexOf('//') == 0) {
// #ifdef APP-PLUS
plus.runtime.openWeb(attrs.href);
// #endif
// #ifndef APP-PLUS
uni.setClipboardData({
data: attrs.href,
success: () =>
uni.showToast({
title: '链接已复制'
})
})
// #endif
} else
uni.navigateTo({
url: attrs.href
})
}
}
},
error(e) {
var context, target = e.currentTarget,
source = target.dataset.from;
if (source == 'video' || source == 'audio') {
// 加载其他 source
var index = this.controls[target.id] ? this.controls[target.id].index + 1 : 1;
if (index < target.dataset.source.length)
this.$set(this.controls, target.id + '.index', index);
if (source == 'video') context = uni.createVideoContext(target.id, this);
}
this.top && this.top.$emit('error', {
source,
target,
errMsg: e.detail.errMsg,
errCode: e.detail.errCode,
context
});
},
_loadVideo(e) {
this.$set(this.controls, e.currentTarget.id, {
play: true,
index: 0
})
}
}
}
</script>
<style>
/* 在这里引入自定义样式 */
/* 链接和图片效果 */
._a {
display: inline;
color: #366092;
word-break: break-all;
padding: 1.5px 0 1.5px 0;
}
._hover {
opacity: 0.7;
text-decoration: underline;
}
._img {
display: inline-block;
text-indent: 0;
}
/* #ifdef MP-WEIXIN */
:host {
display: inline;
}
/* #endif */
/* #ifdef MP */
.interlayer {
align-content: inherit;
align-items: inherit;
display: inherit;
flex-direction: inherit;
flex-wrap: inherit;
justify-content: inherit;
width: 100%;
white-space: inherit;
}
/* #endif */
._b,
._strong {
font-weight: bold;
}
._blockquote,
._div,
._p,
._ol,
._ul,
._li {
display: block;
}
._code {
font-family: monospace;
}
._del {
text-decoration: line-through;
}
._em,
._i {
font-style: italic;
}
._h1 {
font-size: 2em;
}
._h2 {
font-size: 1.5em;
}
._h3 {
font-size: 1.17em;
}
._h5 {
font-size: 0.83em;
}
._h6 {
font-size: 0.67em;
}
._h1,
._h2,
._h3,
._h4,
._h5,
._h6 {
display: block;
font-weight: bold;
}
._ins {
text-decoration: underline;
}
._li {
flex: 1;
width: 0;
}
._ol-bef {
margin-right: 5px;
text-align: right;
width: 36px;
}
._ul-bef {
line-height: normal;
margin: 0 12px 0 23px;
}
._ol-bef,
._ul_bef {
flex: none;
user-select: none;
}
._ul-p1 {
display: inline-block;
height: 0.3em;
line-height: 0.3em;
overflow: hidden;
width: 0.3em;
}
._ul-p2 {
border: 0.05em solid black;
border-radius: 50%;
display: inline-block;
height: 0.23em;
width: 0.23em;
}
._q::before {
content: '"';
}
._q::after {
content: '"';
}
._sub {
font-size: smaller;
vertical-align: sub;
}
._sup {
font-size: smaller;
vertical-align: super;
}
/* #ifndef MP-WEIXIN */
._abbr,
._b,
._code,
._del,
._em,
._i,
._ins,
._label,
._q,
._span,
._strong,
._sub,
._sup {
display: inline;
}
/* #endif */
/* #ifdef MP-WEIXIN || MP-QQ || MP-ALIPAY */
.__bdo,
.__bdi,
.__ruby,
.__rt,
._entity {
display: inline-block;
}
/* #endif */
._video {
background-color: black;
display: inline-block;
height: 225px;
position: relative;
width: 300px;
}
._video::after {
border-color: transparent transparent transparent white;
border-style: solid;
border-width: 15px 0 15px 30px;
content: '';
left: 50%;
margin: -15px 0 0 -15px;
position: absolute;
top: 50%;
}
</style>

View File

@@ -0,0 +1,268 @@
<template>
<view class="right-wrapper" @touchmove.stop.prevent="moveStop">
<view class="control-wrapper">
<view class='cart_nav'>
<nav-bar navTitle='筛选' :isShowBack="false" :isShowMenu="false" iconColor='#282828' :isBackgroundColor="false" backgroundColor="#fff" ref="navBarRef"></nav-bar>
</view>
<view class="content-box">
<view class="acea-row mt-24 flex-between-center mb-20">
<view class="title line-heightOne">店铺类型</view>
<view class="btns" v-if="!isShow && merchantType.length>9" @click="isShow = true">展开<text class="iconfont icon-ic_downarrow"></text></view>
<view class="btns" v-if="isShow && merchantType.length>9" @click="isShow = false">收起<text class="iconfont icon-ic_uparrow"></text></view>
</view>
<view class="brand-wrapper">
<scroll-view :style="{'height':isShow?'100%':'240rpx'}" :scroll-y="isShow">
<view class="wrapper">
<view class="item line1 f-s-22 flex-center" v-for="(item,index) in merchantType" :key="index" :class="activeIndex === index ? 'on' : ' '" @tap="bindChenck1(index)">
{{item.name}}
</view>
</view>
</scroll-view>
</view>
<view class="flex-between-center line-heightOne mt-54 mb-20">
<view class="title line-heightOne">商户分类</view>
<view class="btns" v-if="!isShowCate && merchantClassify.length>8" @click="isShowCate = true">展开<text class="iconfont icon-ic_downarrow"></text></view>
<view class="btns" v-if="isShowCate && merchantClassify.length>8" @click="isShowCate = false">收起<text class="iconfont icon-ic_uparrow"></text></view>
</view>
<view class="brand-wrapper">
<scroll-view :style="{'height':isShowCate?'100%':'240rpx'}" :scroll-y="isShowCate">
<view class="wrapper">
<view class="item line1 f-s-22 flex-center" v-for="(item,index) in merchantClassify" :key="index" :class="activeIndex2 === index ? 'on' : ' '" @tap="bindChenck2(index)">
{{item.name}}
</view>
</view>
</scroll-view>
</view>
</view>
<view class="foot-btn bg--w111-fff w-100-p111- flex-center pb-30">
<view class="btn-item mt-30" @click="reset">重置</view>
<view class="btn-item confirm mt-30" @click="confirm">确定</view>
</view>
</view>
<view class="right-bg" @click="close"></view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import { mapGetters } from "vuex";
import navBar from '@/components/navBar';
export default{
computed: mapGetters(["merchantClassify", "merchantType"]),
components: {
navBar
},
props:{
whereMer:{
type:Object,
default:function(){
return {}
}
}
},
data(){
return {
min: '',
max:'',
isShow:false,
isShowCate: false,
list:[],
merCate: [],
activeList:[],
selectList: [],
activeIndex: null,
activeIndex2: null,
}
},
watch:{
whereMer:{
handler:function(newV,oldV){
if(newV){
this.typeId = this.whereMer.typeIds;
this.categoryId = this.whereMer.categoryIds;
if(this.typeId == '') this.activeIndex =null;
if(this.categoryId == '') this.activeIndex2 =null;
}
},
deep:true
}
},
methods:{
bindChenck1(index){
this.activeIndex = index
this.typeId = this.merchantType[index].id
},
bindChenck2(index){
this.activeIndex2 = index
this.categoryId = this.merchantClassify[index].id
},
reset(){
this.activeIndex = null
this.activeIndex2 = null
this.typeId = ''
this.categoryId = ''
},
confirm(){
let obj = {
typeId:this.typeId,
categoryId: this.categoryId
}
this.$emit('confirm',obj)
},
close(){
this.$emit('close')
},
moveStop(){}
}
}
</script>
<style lang="scss" scoped>
/deep/.nav_title{
font-size: 34rpx !important;
font-weight: 600;
}
.right-wrapper{
width: 670rpx;
background: #FFFFFF;
box-sizing: border-box;
height: 100%;
overflow: auto;
.control-wrapper{
z-index: 90;
position: absolute;
right: 0;
top: 0;
display: flex;
flex-direction: column;
height: 100%;
background-color: #F5F5F5;
.btns{
display: flex;
align-items: center;
justify-content: center;
padding-bottom: 6rpx;
font-size: 22rpx;
color: #999;
.iconfont{
margin-left: 10rpx;
margin-top: 5rpx;
font-size: 20rpx;
}
}
.header{
padding: 50rpx 26rpx 40rpx;
background-color: #fff;
.title{
font-size: 26rpx;
font-weight: bold;
color: #282828;
}
.input-wrapper{
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 28rpx;
input{
width:260rpx;
height:56rpx;
padding: 0 10rpx;
background:rgba(242,242,242,1);
border-radius:28rpx;
font-size: 22rpx;
text-align: center;
}
.line{
width:15rpx;
height:2rpx;
background:#7D7D7D;
}
}
}
.content-box{
position: relative;
flex: 1;
display: flex;
flex-direction: column;
padding: 0 26rpx;
background-color: #fff;
overflow: auto;
/* #ifdef MP || APP-PLUS */
padding-bottom: 60rpx;
padding-bottom: calc(60rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
padding-bottom: calc(60rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
/* #endif */
/* #ifdef H5 */
margin-bottom: 120rpx;
/* #endif */
.title{
font-size: 26rpx;
font-weight: bold;
color: #282828;
}
.brand-wrapper{
// flex: 1;
overflow: hidden;
.wrapper{
display: flex;
flex-wrap: wrap;
padding-bottom: 20rpx;
margin-top: -16rpx;
}
.item{
width:186rpx;
height:56rpx;
background:rgba(242,242,242,1);
border-radius:28rpx;
margin-top: 26rpx;
padding: 0 10rpx;
margin-right: 20rpx;
&:nth-child(3n){
margin-right: 0;
}
&.on{
@include main_color(theme);
@include main_rgba_color(theme);
@include coupons_border_color(theme);
}
}
}
}
}
.foot-btn{
position: absolute;
bottom: 0;
.btn-item{
display: flex;
align-items: center;
justify-content: center;
width:286rpx;
height:68rpx;
background:rgba(255,255,255,1);
border:1px solid rgba(170,170,170,1);
border-radius:34rpx;
font-size: 26rpx;
color: #282828;
&.confirm{
@include main_bg_color(theme);
@include coupons_border_color(theme);
color: #fff;
margin-left: 20rpx;
}
}
}
.right-bg{
width: 100%;
height: 100%;
background-color: rgba(0,0,0,.5);
}
}
</style>

View File

@@ -0,0 +1,224 @@
<template>
<view class="product-bg new-users">
<swiper :indicator-dots="indicatorDots" :indicator-active-color="indicatorBg" :autoplay="autoplay"
:circular="circular" :interval="interval" :duration="duration" @change="change" v-if="isPlay">
<!-- #ifndef APP-PLUS -->
<swiper-item v-if="videoline">
<view class="item">
<view v-show="!controls" style="width: 100%; height: 100%">
<video id="myVideo" :src="videoline" objectFit="cover" controls
style="width: 100%; height: 100%" show-center-play-btn show-mute-btn="true"
auto-pause-if-navigate :custom-cache="false" :enable-progress-gesture="false"
:poster="imgUrls[0]" @pause="videoPause"></video>
</view>
<view class="poster" v-show="controls">
<image class="image" :src="imgUrls[0]"></image>
</view>
<view class="stop" v-show="controls" @tap="bindPause">
<image class="image" src="../../static/images/stop.png"></image>
</view>
</view>
</swiper-item>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<swiper-item v-if="videoline">
<view class="item">
<view class="poster" v-show="controls">
<image class="image" :src="imgUrls[0]"></image>
</view>
<view class="stop" v-show="controls" @tap="bindPause">
<image class="image" src="../../static/images/stop.png"></image>
</view>
</view>
</swiper-item>
<!-- #endif -->
<block v-for="(item, index) in imgUrls" :key="index">
<swiper-item v-if="videoline ? index >= 1 : index >= 0">
<image :src="item" class="slide-image" />
</swiper-item>
</block>
</swiper>
<!-- #ifdef APP-PLUS -->
<view v-if="!isPlay" style="width: 100%; height: 750rpx">
<video id="myVideo" :src="videoline" objectFit="cover" controls style="width: 100%; height: 100%"
show-center-play-btn show-mute-btn="true" autoplay="true" auto-pause-if-navigate :custom-cache="false"
:enable-progress-gesture="false" :poster="imgUrls[0]" @pause="videoPause"></video>
</view>
<!-- #endif -->
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
setThemeColor
} from "@/utils/setTheme.js";
import {
ProductTypeEnum,
ProductMarketingTypeEnum
} from "@/enums/productEnums";
export default {
props: {
imgUrls: {
type: Array,
default: function() {
return [];
},
},
videoline: {
type: String,
value: "",
},
isGroup: {
type: Number,
value: 0,
},
//商品类型
productType: {
type: Number,
value: 0,
},
// 是否是拼团、秒杀、积分商品,用红色不用主题色
isMarketingGoods: {
type: Boolean,
default: () => false
}
},
data() {
return {
ProductMarketingTypeEnum: ProductMarketingTypeEnum,
ProductTypeEnum: ProductTypeEnum,
indicatorDots: true,
circular: true,
autoplay: true,
interval: 3000,
duration: 500,
currents: "1",
controls: true,
isPlay: true,
videoContext: "",
};
},
computed: {
indicatorBg() {
if (!this.isMarketingGoods) {
return setThemeColor()
}else{
return '#e93323'
}
}
},
mounted() {
if (this.videoline) {
this.imgUrls.shift();
}
// #ifndef APP-PLUS
this.videoContext = uni.createVideoContext("myVideo", this);
// #endif
},
methods: {
videoPause(e) {
// #ifdef APP-PLUS
this.isPlay = true;
this.autoplay = true;
// #endif
},
bindPause: function() {
// #ifndef APP-PLUS
this.videoContext.play();
this.$set(this, "controls", false);
this.autoplay = false;
// #endif
// #ifdef APP-PLUS
this.isPlay = false;
this.videoContext = uni.createVideoContext("myVideo", this);
this.videoContext.play();
// #endif
},
change: function(e) {
this.$set(this, "currents", e.detail.current + 1);
},
},
};
</script>
<style scoped lang="scss">
.product-bg {
width: 100%;
height: 750rpx !important;
position: relative;
}
.product-bg swiper {
width: 100%;
height: 100%;
position: relative;
}
.product-bg .slide-image {
width: 100%;
height: 100%;
}
.product-bg .pages {
position: absolute;
background-color: #fff;
height: 34rpx;
padding: 0 10rpx;
border-radius: 3rpx;
right: 30rpx;
bottom: 30rpx;
line-height: 34rpx;
font-size: 24rpx;
color: #050505;
}
#myVideo {
width: 100%;
height: 100%;
}
.product-bg .item {
position: relative;
width: 100%;
height: 100%;
}
.product-bg .item .poster {
position: absolute;
top: 0;
left: 0;
height: 750rpx;
width: 100%;
z-index: 9;
}
.product-bg .item .poster .image {
width: 100%;
height: 100%;
}
.product-bg .item .stop {
position: absolute;
top: 50%;
left: 50%;
width: 136rpx;
height: 136rpx;
margin-top: -68rpx;
margin-left: -68rpx;
z-index: 9;
}
.product-bg .item .stop .image {
width: 100%;
height: 100%;
}
</style>

View File

@@ -0,0 +1,204 @@
<template>
<view class='list acea-row row-between-wrapper pt-10 relative'
:class="[is_switch==true ? '' : 'on', (merId > 0 || cid > 0) ? 'mer-list' : ''] ">
<view class='item' :class='is_switch==true?"":"on"' hover-class='none' v-for="(item,index) in productLists"
:key="index" @click="goDetail(item)">
<view class='pictrue relative' :class='is_switch==true?"":"on"'>
<view v-show="item.stock===0" class="sellOut">已售罄</view>
<easy-loadimage :image-src="item.image" :class='is_switch==true?"":"on"' radius="16rpx" width="240rpx" height="240rpx">
</easy-loadimage>
<span class="pictrue_log_class" :class="is_switch === true ? 'pictrue_log_big' : 'pictrue_log'"
v-if="item.activityH5 && item.activityH5.type === '1'">秒杀</span>
<span class="pictrue_log_class" :class="is_switch === true ? 'pictrue_log_big' : 'pictrue_log'"
v-if="item.activityH5 && item.activityH5.type === '2'">砍价</span>
<span class="pictrue_log_class" :class="is_switch === true ? 'pictrue_log_big' : 'pictrue_log'"
v-if="item.activityH5 && item.activityH5.type === '3'">拼团</span>
</view>
<view class='text flex-col justify-between' :class='is_switch==true?"":"on"'>
<view class='name box-line2 line2'>
<span v-if="item.productTags && item.productTags.locationLeftTitle.length"
class="font-bg-red mr10 merType bg-color">{{item.productTags.locationLeftTitle[0].tagName}}</span>
{{item.name}}
</view>
<!-- 价格 -->
<view>
<view v-if="item.productTags && item.productTags.locationUnderTitle.length" class="flex flex-wrap pad2">
<text
v-for="items in item.productTags.locationUnderTitle.length>3?item.productTags.locationUnderTitle.slice(0,3):item.productTags.locationUnderTitle"
:key="items.id" class="mr10 tagSolid">{{items.tagName}}</text>
</view>
<view class="mt-10">
<svip-price :svipIconStyle="svipIconStyle" :productPrice="item"
:svipPriceStyle="svipPriceStyle"></svip-price>
</view>
<view class='vip acea-row row-between-wrapper mt-10 line-heightOne' :class='is_switch==true?"":"on"'>
<view class="text-666">已售{{item.sales}}{{item.unitName}}</view>
</view>
<view v-if="item.merName" class="company line-heightOne mt-8rpx" @click.stop="goStore(item.merId)">
<text class='name line1'>{{item.merName}}</text>
<view class="flex">
进店
<text class="iconfont f-s-22 icon-ic_rightarrow"></text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import svipPrice from '@/components/svipPrice.vue';
import easyLoadimage from '@/components/base/easy-loadimage.vue';
import {goProductDetail} from "../../../../libs/order";
export default {
components: {
svipPrice,
easyLoadimage
},
props: {
//商品列表
productLists: {
type: Array,
default: function() {
return []
}
},
is_switch: {
type: Boolean,
default: false,
},
// 商户id
merId: {
type: Number,
default: 0,
},
// 分类
cid: {
type: Number,
default: 0,
},
},
data(){
return {
//普通价格
svipPriceStyle: {
svipBox: {
height: '26rpx',
borderRadius: '60rpx 56rpx 56rpx 20rpx',
},
icon: {
height: '26rpx',
fontSize: '18rpx',
borderRadius: '12rpx 0 12rpx 2rpx'
},
price: {
fontSize: '38rpx'
},
svipPrice: {
fontSize: '22rpx'
}
},
//svip价格
svipIconStyle: {
svipBox: {
height: '26rpx',
borderRadius: '24rpx 40rpx 40rpx 0.4rpx',
},
price: {
fontSize: '38rpx'
},
svipPrice: {
fontSize: '18rpx'
}
},
}
},
methods: {
goStore(id) {
this.$util.goToMerHome(id)
},
// 去详情页
goDetail(item) {
goProductDetail(item.id, 0,'');
},
}
}
</script>
<style scoped lang="scss">
.company {
display: flex;
align-items: center;
color: #666666 !important;
font-size: 22rpx;
.name {
display: inline-block;
// width: 120rpx;
height: auto !important;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.flex {
display: flex;
align-items: center;
margin-left: 10rpx;
color: #282828 !important;
width: 100rpx;
}
}
.list.on {
background-color: #fff;
}
.list .item {
width: 335rpx;
background-color: #fff;
border-radius: 14rpx;
margin-bottom: 20rpx;
}
.list .item.on {
width: 100%;
display: flex;
padding: 0 24rpx 32rpx 24rpx;
margin: 0;
border-radius: 14rpx;
}
.list .item .text {
padding: 18rpx 20rpx;
font-size: 30rpx;
color: #222;
}
.list .item .text.on {
width: 456rpx;
padding: 0 0 0 20rpx;
position: relative;
}
.list .item .text .money {
font-size: 26rpx;
font-weight: bold;
margin-top: 8rpx;
}
.list .item .text .money.on {
margin-top: 50rpx;
}
.list .item .text .money .num {
font-size: 34rpx;
}
.list .item .text .vip {
font-size: 22rpx;
color: #aaa;
}
</style>

View File

@@ -0,0 +1,58 @@
<template>
<view v-if="shareInfoStatus" class="poster-first">
<view class="mask-share">
<image :src="urlDomain+'crmebimage/presets/share-info.png'" @click="shareInfoClose" @touchmove.stop.prevent="false"></image>
</view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
export default {
props: {
shareInfoStatus: {
type: Boolean,
default: false,
}
},
data: function() {
return {
urlDomain: this.$Cache.get("imgHost"),
};
},
mounted: function() {},
methods: {
shareInfoClose: function() {
this.$emit("setShareInfoStatus");
}
}
};
</script>
<style scoped lang="scss">
.poster-first {
overscroll-behavior: contain;
}
.mask-share {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 99;
}
.mask-share image {
width: 100%;
height: 100%;
}
</style>

View File

@@ -0,0 +1,542 @@
<template>
<!--商品关联系统表单-->
<view v-if="value.length>0">
<view class='bg--w111-fff borRadius14 mt20 virtual_form'
:class="{on:(list.name=='radios' || list.name=='checkboxs'),on2:list.name == 'dateranges',on3:list.name == 'citys',pd0:list.name == 'uploadPicture'}"
v-for="(list,indexs) in orderNewForm" :key="indexs">
<view v-for="(item,index) in list" :key="index">
<!-- 富文本-->
<view v-if="item.name=='richTextEditor'">
<text-editor :richTextVal="item.richText.val"></text-editor>
</view>
<view class='item acea-row row-between-wrapper w-100-p111-'>
<view v-if="item.name!=='richTextEditor'" class="name">
<text class="item-require" v-if="item.titleShow && item.titleShow.val">*</text>
{{ item.titleConfig.val }}
</view>
<!-- radio -->
<view v-if="item.name=='radios'" class="discount">
<radio-group @change="radioChange($event, indexs, index, item)"
class="acea-row row-middle row-right">
<label class="radio" v-for="(j,jindex) in item.wordsConfig.list" :key="jindex">
<view class="acea-row row-middle">
<!-- #ifndef MP -->
<radio :value="jindex.toString()" :checked='j.show' />
<!-- #endif -->
<!-- #ifdef MP -->
<radio :value="jindex" :checked='j.show' />
<!-- #endif -->
<view>{{j.val}}</view>
</view>
</label>
</radio-group>
</view>
<!-- checkbox -->
<view v-if="item.name=='checkboxs'" class="discount acea-row">
<checkbox-group @change="checkboxChange($event, indexs, index, item)"
class="acea-row row-middle row-right">
<label class="radio" v-for="(j,jindex) in item.wordsConfig.list" :key="jindex">
<view class="acea-row row-middle">
<checkbox :value="jindex.toString()" :checked="j.show"
style="transform:scale(0.9)" />
<view class="ml-8">{{j.val}}</view>
</view>
</label>
</checkbox-group>
</view>
<!-- text -->
<view v-if="item.name=='texts' && item.valConfig.tabVal == 0" class="discount">
<input type="text" :placeholder="item.tipConfig.val" class="text-28rpx"
placeholder-class="placeholder" v-model="item.value" />
</view>
<!-- number -->
<view v-if="item.name=='texts' && item.valConfig.tabVal == 4" class="discount">
<input type="number" :placeholder="item.tipConfig.val" class="text-28rpx"
placeholder-class="placeholder" v-model="item.value" />
</view>
<!-- email -->
<view v-if="item.name=='texts' && item.valConfig.tabVal == 3" class="discount">
<input type="text" :placeholder="item.tipConfig.val" class="text-28rpx"
placeholder-class="placeholder" v-model="item.value" />
</view>
<!-- data -->
<view v-if="item.name=='dates'" class="discount">
<picker mode="date" :value="item.value" @change="bindDateChange($event,indexs,index)">
<view class="acea-row row-between-wrapper text-28rpx">
<view v-if="item.value == ''" class="text--w111-ccc">{{item.tipConfig.val}}</view>
<view v-else>{{item.value}}</view>
<text class='iconfont icon-ic_rightarrow'></text>
</view>
</picker>
</view>
<!-- dateranges -->
<view v-if="item.name=='dateranges'" class="discount">
<uni-datetime-picker v-model="item.value" type="daterange" class="text-28rpx flex"
@maskClick="maskClick">
<view v-if="item.value == ''" class="text--w111-ccc">请选择</view>
<view v-else>{{item.value.length?item.value[0]+' - '+item.value[1]:item.tipConfig.val}}
</view>
<text class='iconfont icon-ic_rightarrow'></text>
</uni-datetime-picker>
</view>
<!-- time -->
<view v-if="item.name=='times'" class="discount">
<picker mode="time" :value="item.value" @change="bindTimeChange($event, indexs, index)"
:placeholder="item.tipConfig.value">
<view class="acea-row row-between-wrapper text-28rpx">
<view v-if="item.value == ''" class="text--w111-ccc">{{item.tipConfig.val}}</view>
<view v-else>{{item.value}}</view>
<text class='iconfont icon-ic_rightarrow'></text>
</view>
</picker>
</view>
<!-- timeranges -->
<view v-if="item.name=='timeranges'" class="discount acea-row row-between-wrapper"
@click="getTimeranges(indexs, index)">
<view v-if="item.value" class="text-28rpx">{{item.value}}</view>
<view v-else class="text--w111-ccc text-28rpx">{{item.tipConfig.val}}</view>
<text class='iconfont icon-ic_rightarrow'></text>
</view>
<!-- select -->
<view v-if="item.name=='selects'" class="discount">
<picker :value="item.value" :range="item.wordsConfig.list"
@change="bindSelectChange($event, indexs, index,item)" range-key="val">
<view class="acea-row row-between-wrapper">
<view v-if="item.value" class="text-28rpx">{{item.value}}</view>
<view v-else class="text--w111-ccc text-28rpx">请选择</view>
<text class='iconfont icon-ic_rightarrow'></text>
</view>
</picker>
</view>
<!-- city -->
<view v-if="item.name=='citys'" class="discount acea-row" @click="changeRegion(indexs, index)">
<view class="acea-row row-middle row-right">
<view class="city text--w111-ccc" v-if="item.value == ''">{{item.tipConfig.val}}</view>
<view class="city text-28rpx" v-else>{{item.value}}</view>
<text class='iconfont icon-ic_rightarrow'></text>
</view>
</view>
<!-- id -->
<view v-if="item.name=='texts' && item.valConfig.tabVal == 2" class="discount">
<input type="idcard" :placeholder="item.tipConfig.val" class="text-28rpx"
placeholder-class="placeholder" v-model="item.value" />
</view>
<!-- phone -->
<view v-if="item.name=='texts' && item.valConfig.tabVal == 1" class="discount">
<input type="number" :placeholder="item.tipConfig.val" class="text-28rpx"
placeholder-class="placeholder" v-model="item.value" />
</view>
<!-- img -->
<view v-if="item.name=='uploadPicture'" class="confirmImg" style="padding-bottom: 0;">
<view class='upload acea-row row-middle justify-end'>
<view class='pictrue' v-for="(items,idx) in item.value" :key="idx">
<image :src='items' mode="aspectFill"></image>
<view class="close acea-row row-center-wrapper" @tap='DelPic(indexs,index,idx)'>
<view class="iconfont icon-ic_close1"></view>
</view>
</view>
<view class='pictrue acea-row row-center-wrapper row-column' @tap='uploadpic(indexs,index)'
style="margin-right: 0" v-if="item.value.length < item.numConfig.val">
<view>上传图片</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 时间选择 -->
<timerangesFrom :isShow='isShow' :time='timeranges' @confrim="confrim" @cancel="cancels"></timerangesFrom>
<areaWindow ref="areaWindow" :display="display" :address='addressInfoArea' :cityShow='cityShow'
@submit="OnChangeAddress" @changeClose="changeAddressClose"></areaWindow>
</view>
</template>
<script>
import areaWindow from '../areaWindow';
import timerangesFrom from '../timeranges';
// import uniDatetimePicker from '../uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue';
import dayjs from "@/plugin/dayjs/dayjs.min.js";
import textEditor from "../../../../components/textEditor";
const CACHE_CITY = {};
export default {
props: {
value: {
type: Array,
default: function() {
return []
}
},
},
components: {
areaWindow,
timerangesFrom,
textEditor
// uniDatetimePicker
},
data() {
return {
orderNewForm: [],
isShow: false,
timerangesIndex: 0,
display: false,
addressInfoArea: [],
cityShow: 2,
timeranges: [],
orderExtend: {}, //提交接口表单的数据
}
},
watch: {
orderNewForm: {
handler(newVal) {
this.$emit('input', newVal);
},
deep: true,
},
},
mounted() {
this.getFromData()
},
methods: {
getFormList(count) {
let arr = []
let data = this.getFromData()
for (var i = 0; i < count; i++) {
arr.push(JSON.parse(JSON.stringify(data)))
}
this.$set(this, 'orderNewForm', arr);
// this.orderNewForm = arr
},
getFromData(form) {
let formData = [...this.value];
formData.forEach((item, index, arr) => {
this.$set(item, 'value', "");
CACHE_CITY[index] = ''; //清空省市区
if (item.name == 'texts') {
if (item.defaultValConfig.val) {
item.value = item.defaultValConfig.val
} else {
item.value = ''
}
}else if (item.name == 'richTextEditor') {
item.value = item.richText.val
} else if (item.name == 'radios') {
item.value = item.wordsConfig.list[0].val
} else if (item.name == 'uploadPicture') {
item.value = [];
} else if (item.name == 'dateranges') {
if (item.valConfig.tabVal == 0) {
if (item.valConfig.tabData == 0) {
let obj = dayjs(new Date(Number(new Date().getTime()))).format('YYYY-MM-DD');
item.value = [obj, obj]
} else {
let data1 = dayjs(new Date(Number(new Date(item.valConfig.specifyDate[0])
.getTime()))).format('YYYY-MM-DD');
let data2 = dayjs(new Date(Number(new Date(item.valConfig.specifyDate[1])
.getTime()))).format('YYYY-MM-DD');
item.value = [data1, data2];
}
} else {
item.value = [];
}
} else {
if (['times', 'dates', 'timeranges'].indexOf(item.name) != -1) {
if (item.valConfig && item.valConfig.tabVal == 0) { //显示默认值
if (item.valConfig.tabData == 0) {
if (item.name == 'times') {
item.value = dayjs(new Date(Number(new Date().getTime()))).format('HH:mm');
} else if (item.name == 'dates') {
item.value = dayjs(new Date(Number(new Date().getTime()))).format(
'YYYY-MM-DD');
} else {
let current = dayjs(new Date(Number(new Date().getTime()))).format(
'HH:mm');
item.value = current + ' - ' + current;
}
} else {
if (item.name == 'times' || item.name == 'dates') {
item.value = item.valConfig.specifyDate;
} else {
item.value = item.valConfig.specifyDate[0] + ' - ' + item.valConfig
.specifyDate[1];
}
}
} else {
item.value = '';
}
} else {
item.value = '';
}
}
})
function sortNumber(a, b) {
return a.timestamp - b.timestamp;
}
formData.sort(sortNumber);
return formData
//this.$set(this, 'orderNewForm', formData);
},
getSubmitFromData(num) {
let systemFormValue = Array.from(this.orderNewForm)
let systemFormData = [] //处理后的系统表单值
for (var i = 0; i < systemFormValue.length; i++) {
let reservation = []
for (var j = 0; j < systemFormValue[i].length; j++) {
let curdata = systemFormValue[i][j]
if (['radios'].indexOf(curdata.name) == -1 && (curdata.titleShow && curdata.titleShow.val || (['uploadPicture',
'dateranges'
].indexOf(curdata.name) == -1 && curdata.value && curdata.value.trim()))) {
if ((curdata.name === 'texts' && curdata.valConfig.tabVal == 0) || ['dates', 'times',
'selects', 'citys', 'checkboxs','richTextEditor'
].indexOf(curdata.name) != -1) {
if (!curdata.value || (curdata.value && !curdata.value.trim())) {
return this.$util.Tips({
title: `请填写第${i+1}个表单的${curdata.titleConfig.val}`
});
}
}
if (curdata.name === 'timeranges') {
if (!curdata.value) {
return this.$util.Tips({
title: `请选择${i+1}个表单的${curdata.titleConfig.val}`
});
}
}
if (curdata.name === 'dateranges') {
if (!curdata.value.length) {
return this.$util.Tips({
title: `请选择${i+1}个表单的${curdata.titleConfig.val}`
});
}
}
if (curdata.name === 'texts' && curdata.valConfig.tabVal == 4) {
if (curdata.value <= 0) {
return this.$util.Tips({
title: `${i+1}个表单请填写大于0的${curdata.titleConfig.val}`
});
}
}
if (curdata.name === 'texts' && curdata.valConfig.tabVal == 3) {
if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(curdata.value)) {
return this.$util.Tips({
title: `${i+1}个表单请填写正确的${curdata.titleConfig.val}`
});
}
}
if (curdata.name === 'texts' && curdata.valConfig.tabVal == 1) {
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(curdata.value)) {
return this.$util.Tips({
title: `${i+1}个表单请填写正确的${curdata.titleConfig.val}`
});
}
}
if (curdata.name === 'texts' && curdata.valConfig.tabVal == 2) {
if (!
/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/i
.test(curdata.value)) {
return this.$util.Tips({
title: `${i+1}个表单请填写正确的${curdata.titleConfig.val}`
});
}
}
if (curdata.name === 'uploadPicture') {
if (!curdata.value.length) {
return this.$util.Tips({
title: `请上传第${i+1}个表单的${curdata.titleConfig.val}`
});
}
}
}
this.orderExtend[curdata.key] = curdata.value
reservation.push({
title: curdata.titleConfig.val,
value: curdata.value,
})
}
if (num !== 1) {
systemFormData.push(reservation)
} else {
systemFormData = reservation
}
}
return systemFormData
},
// 单选
radioChange(e, i, index, item) {
this.orderNewForm[i][index].value = item.wordsConfig.list[e.detail.value].val
},
// 多选
checkboxChange(e, i, index, item) {
let obj = e.detail.value;
let val = '';
item.wordsConfig.list.forEach((j, jindex) => {
obj.forEach(x => {
if (jindex == x) {
val = val + (val ? ',' : '') + j.val;
}
})
})
this.orderNewForm[i][index].value = val
},
//日期
bindDateChange(e, i, index) {
this.orderNewForm[i][index].value = e.target.value
this.$forceUpdate()
},
//时间
bindTimeChange(e, i, index) {
this.orderNewForm[i][index].value = e.target.value
},
//时间选择
getTimeranges(i, index) {
this.isShow = true
this.formIndex = i;
this.timerangesIndex = index
},
//时间选择回调
confrim(e) {
this.isShow = false;
this.$set(this.orderNewForm[this.formIndex][this.timerangesIndex], 'value', e.time);
let arrayNew = [];
e.val.forEach(item => {
arrayNew.push(Number(item))
})
this.timeranges = arrayNew;
},
//关闭时间选择弹窗
cancels() {
this.isShow = false;
},
//sel选择
bindSelectChange(e, i, index, item) {
this.$set(this.orderNewForm[i][index], 'value', item.wordsConfig.list[e.detail.value].val);
},
//城市地址选择
changeRegion(i, index) {
if (!this.orderNewForm[i][index].value) {
this.addressInfoArea = [];
}
this.timerangesIndex = index;
this.formIndex = i;
this.cityShow = Number(this.orderNewForm[i][index].valConfig.tabVal) + 1;
this.display = true;
if (CACHE_CITY[i]) {
this.addressInfoArea = CACHE_CITY[i];
}
},
//选择地址回调
OnChangeAddress(address) {
// let addr = '';
let addr = address.map(v => v.regionName).join('/');
this.orderNewForm[this.formIndex][this.timerangesIndex].value = addr;
CACHE_CITY[this.timerangesIndex] = address;
},
// 关闭地址弹窗;
changeAddressClose() {
this.display = false;
},
/**上传文件*/
uploadpic(idx, index) {
let that = this;
that.$util.uploadImageOne({
url: 'upload/image',
name: 'multipart',
model: "order",
pid: 0
}, function(res) {
let arr = that.orderNewForm[idx][index]['value'];
//let pics = item.value || []
arr.push(res);
that.$set(that.orderNewForm[idx][index], 'value', arr);
that.$set(that.orderNewForm[idx][index], 'scrollWidth', (arr.length + 1) * 118 + 'rpx');
// that.$set(item, 'value', pics);
});
},
//删除图片
DelPic(idx, index, indexs) {
let pic = this.orderNewForm[idx][index].value;
this.orderNewForm[idx][index].value.splice(indexs, 1);
this.$set(this.orderNewForm[idx][index], 'value', this.orderNewForm[index].value);
},
}
}
</script>
<style scoped lang="scss">
/deep/.uni-date-editor {}
.item {
font-size: 28rpx;
color: #282828;
}
.name {
width: 168rpx;
padding: 20rpx 0;
}
.virtual_form {
padding: 10rpx 24rpx 32rpx 24rpx;
.uni-input-wrapper {
text-align: right;
}
.item-require {
color: red;
margin-right: 4rpx;
}
.item {
.pd0 {
padding-bottom: 0;
}
.radio {
margin: 0 22rpx 0 22rpx;
padding: 10rpx 0;
}
.discount .placeholder {
color: #ccc;
text-align: right;
font-size: 28rpx;
}
.discount {
max-width: 480rpx;
font-size: 28rpx;
text-align: right;
&.discount_voice {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 460rpx;
text-align: right;
}
.num {
font-size: 28rpx;
margin-right: 20rpx;
}
}
}
}
</style>

View File

@@ -0,0 +1,173 @@
<template>
<view>
<view class="time1" :class='isShow==true?"on":""'>
<view class="top acea-row row-between-wrapper">
<text @tap="cancel">取消</text>
<text @tap="confirm">确定</text>
</view>
<picker-view class="picker" :value="value" @change="getime" indicator-style="height:34px;">
<picker-view-column>
<view class="hours" v-for="(item,index) in hoursList" :key="index">{{item}}</view>
</picker-view-column>
<picker-view-column>
<view class="minutes" v-for="(item,index) in minutes" :key="index">{{item}}</view>
</picker-view-column>
<picker-view-column>
<view class="center">-</view>
</picker-view-column>
<picker-view-column>
<view class="hours" v-for="(item,index) in hoursList" :key="index">{{item}}</view>
</picker-view-column>
<picker-view-column>
<view class="minutes" v-for="(item,index) in minutes" :key="index">{{item}}</view>
</picker-view-column>
</picker-view>
</view>
<view class="mask" @tap="cancel" catchtouchmove="true" :hidden="isShow==false"></view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
let minutes=[]
for (let i = 0; i <= 59; i++) {
if(i<10){
i="0"+i
}
minutes.push(i)
}
let hoursList = []
for (let i = 0; i <= 23; i++) {
if(i<10){
i="0"+i
}
hoursList.push(i)
}
export default{
props:{
isShow:{
type: Boolean,
default: false
},
time:{
type: Array,
default() {
return [];
}
}
},
watch:{
time:function(){
this.value=this.time
}
},
created(){
},
data(){
return{
value:this.time,//默认结束开始时间
hoursList,
minutes,
}
},
methods:{
confirm(){
let num0 = this.value[0]?this.value[0]:'00'
let num1 = this.value[1]?this.value[1]:'00'
let num3 = this.value[3]?this.value[3]:'00'
let num4 = this.value[4]?this.value[4]:'00'
let time = num0 +":"+ num1 +" - "+ num3+":"+ num4
if(num3>num0 || (num3 == num0 && num4 >= num1)){
this.$emit("confrim",{time:time,val:this.value})
}else{
return this.$util.Tips({
title: '开始时间必须小于结束时间'
});
}
},
cancel(){
let time = this.value[0]+":"+this.value[1]+" - "+this.value[3]+":"+this.value[4]
this.$emit("cancel",{time:time})
},
getime(e){
let val = e.detail.value
this.value[0] = this.hoursList[val[0]]
this.value[1] = this.minutes[val[1]]
this.value[2] = val[2]
this.value[3] = this.hoursList[val[3]]
this.value[4] = this.minutes[val[4]]
},
}
}
</script>
<style lang="scss" scoped>
.time1{
width:100%;
margin: 0 auto;
background-color:#FFFFFF;
color: #000;
height: 568rpx;
position: fixed;
bottom: 0;
left: 0;
z-index: 99;
transform: translate3d(0, 200%, 0);
transition: all .3s cubic-bezier(.25, .5, .5, .9);
&.on{
transform: translate3d(0, 0, 0);
}
.top{
height: 90rpx;
border-bottom: 1px solid #eee;
padding: 0 30rpx;
text{
font-size: 32rpx;
&:nth-child(1){
color: #888;
}
&:nth-child(2){
color: #007aff;
}
}
}
.tip12{
width: 100%;
height: 100rpx;
view{
width: 50%;
text-align: center;
line-height: 100rpx;
font-size: 40rpx;
color: #000000;
}
}
.hours{
font-size: 32rpx;
color: #000;
line-height:34px;
text-align: center;
}
.minutes{
font-size: 32rpx;
color: #000;
line-height:34px;
text-align: center;
}
.center{
line-height:34px;
text-align: center;
}
}
.picker{
width: 100%;
height: 476rpx;
}
</style>

View File

@@ -0,0 +1,162 @@
<template>
<!-- v-if="reply.length>0" -->
<view class="evaluateWtapper" v-if="reply.length>0">
<view class="evaluateItem borRadius14 mb20" v-for="(item, indexw) in reply" :key="indexw">
<view class="pic-text acea-row px-24 py-24">
<view class="pictrue">
<image :src="item.avatar"></image>
</view>
<view class="content">
<view>
<view class="acea-row row-between">
<view class="acea-row items-center">
<view class="name line1">{{ item.nickname }}</view>
<view v-if="item.isLogoff === true" class="name line1">已注销</view>
<view class="start ml-8" :class="'star' + item.star"></view>
</view>
<view class="time">{{ item.createTime }}</view>
</view>
<view class="sku">规格{{ item.sku?item.sku:'无' }}</view>
</view>
<view class="evaluate-infor">{{ item.comment }}</view>
<view class="imgList acea-row" v-if="item.pics && item.pics.length && item.pics[0]">
<view class="pictrue" v-for="(itemn, indexn) in item.pics" :key="indexn">
<image :src="itemn" class="image" @click='getpreviewImage(indexw, indexn)'></image>
</view>
</view>
<view class="reply" v-if="item.merchantReplyContent">
<text class="font_color">店小二</text>{{ item.merchantReplyContent }}
</view>
</view>
</view>
</view>
</view>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
export default {
props: {
reply: {
type: Array,
default: () => []
}
},
data: function() {
return {};
},
methods: {
getpreviewImage: function(indexw, indexn) {
uni.previewImage({
urls: this.reply[indexw].pics,
current: this.reply[indexw].pics[indexn]
});
}
}
}
</script>
<style scoped lang='scss'>
.evaluateWtapper .evaluateItem {
background-color: #fff;
}
.evaluateWtapper .evaluateItem~.evaluateItem {
border-top: 1rpx solid #f5f5f5;
}
.evaluateWtapper .evaluateItem .pic-text {
font-size: 26rpx;
color: #282828;
.content{
width: 84%;
margin-left: 20rpx;
}
}
.evaluateWtapper .evaluateItem .pic-text .pictrue {
width: 62rpx;
height: 62rpx;
}
.evaluateWtapper .evaluateItem .pic-text .pictrue image {
width: 100%;
height: 100%;
border-radius: 50%;
}
.evaluateWtapper .evaluateItem .pic-text .name {
max-width: 450rpx;
}
.evaluateWtapper .evaluateItem .time {
font-size: 24rpx;
color: #999999;
}
.sku{
font-size: 24rpx;
color: #999999;
margin: 10rpx 0;
}
.evaluateWtapper .evaluateItem .evaluate-infor {
font-size: 28rpx;
color: #333;
margin-bottom: 14rpx;
}
.evaluateWtapper .evaluateItem .imgList {/*
padding: 0 24rpx;
margin-top: 16rpx; */
}
.evaluateWtapper .evaluateItem .imgList .pictrue {
width: 156rpx;
height: 156rpx;
margin-right: 14rpx;
border-radius: 16rpx;
margin-bottom: 16rpx;
/* margin: 0 0 15rpx 15rpx; */
}
.evaluateWtapper .evaluateItem .imgList .pictrue image {
width: 100%;
height: 100%;
background-color: #f7f7f7;
border-radius: 14rpx;
}
.evaluateWtapper .evaluateItem .reply {
font-size: 26rpx;
color: #454545;
background-color: #f7f7f7;
border-radius: 14rpx;
margin: 20rpx 30rpx 0 0rpx;
padding: 20rpx;
position: relative;
}
.evaluateWtapper .evaluateItem .reply::before {
content: "";
width: 0;
height: 0;
border-left: 20rpx solid transparent;
border-right: 20rpx solid transparent;
border-bottom: 30rpx solid #f7f7f7;
position: absolute;
top: -14rpx;
left: 40rpx;
}
.font_color{
@include main_color(theme);
}
</style>