Commit ac524802 authored by home's avatar home

zxf

parent fed5ec73
......@@ -123,7 +123,8 @@
console.log('这里')
let res = await newsRemind({
uid:this.$store.state.userInfo.user_id,
cid:cid
cid:cid,
});
if(res.code==0){
......
<template>
<view class="date-time-picker" v-if="visible">
<view class="date-time-mask" @click.stop="hide"></view>
<view class="date-time-container" @click.stop="handleEvent">
<view class="time-picker-tool" v-if='isShowToolBar'>
<view :class="[cancelButtonClass]" @click.stop="cancel">
<text>{{cancelButtonText}}</text>
</view>
<view :class="[toolBarTitleClass]">
<text>{{toolBarTitle}}</text>
</view>
<view :class="[confirmButtonClass]" @click.stop="confirm">
<text>{{confirmButtonText}}</text>
</view>
</view>
<picker-view class="picker-view" :indicator-style="indicatorStyleString" :value="dateTime" @change="dateTimePickerChange">
<picker-view-column data-id='year' v-if='isShowYear'>
<view class="item" v-for="(item,index) in years" :key="index">{{item}}</view>
</picker-view-column>
<picker-view-column data-id='month' v-if='isShowMonth'>
<view class="item" v-for="(item,index) in months" :key="index">{{item}}</view>
</picker-view-column>
<picker-view-column data-id='day' v-if='isShowDay'>
<view class="item" v-for="(item,index) in days" :key="index">{{item}}</view>
</picker-view-column>
<picker-view-column data-id='hour' v-if='isShowHour'>
<view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view>
</picker-view-column>
<picker-view-column data-id='minute' v-if='isShowMinute'>
<view class="item" v-for="(item,index) in minutes" :key="index">{{item}}</view>
</picker-view-column>
<picker-view-column data-id='second' v-if='isShowSecond'>
<view class="item" v-for="(item,index) in seconds" :key="index">{{item}}</view>
</picker-view-column>
</picker-view>
</view>
</view>
</template>
<script>
import {
getOneMonthDays,
getTimeArray,
addZero,
getIndexOfArray
} from './uitls/util.js'
export default {
name: 'DateTimePicker',
props: {
startYear: {
type: Number,
default: 1900
},
endYear: {
type: Number,
default: new Date().getFullYear()
},
isShowToolBar: {
type: Boolean,
default: true
},
cancelButtonText: {
type: String,
default: '取消'
},
cancelButtonClass: {
type: String,
default: 'cancel-btn'
},
toolBarTitle: {
type: String,
default: '请选择'
},
toolBarTitleClass: {
type: String,
default: 'tool-title'
},
confirmButtonText: {
type: String,
default: '确定'
},
confirmButtonClass: {
type: String,
default: 'confirm-btn'
},
datestring: {
type: String,
default: ''
},
type: {
/**
* date 年月日
* year-month 年月
* year 年
* datetime 年月日 时分
* datetime-all 年月日 时分秒
* time 时分秒
* hour-minute 时分
*/
type: String,
default: 'date'
},
indicatorStyle: {
type: Object,
default: null
}
},
data() {
return {
visible: false,
dateTime: [],
days: [],
indicatorStyleString: ''
}
},
watch: {
indicatorStyle(val){
this.getIndicatorStyle();
},
type() {
this.initDateTime()
},
datestring(){
this.initDateTime()
}
},
computed: {
years() {
return this.initTimeData(this.endYear, this.startYear);
},
isShowYear() {
return this.type !== 'time' && this.type !== 'hour-minute';
},
months() {
return this.initTimeData(12, 1);
},
isShowMonth() {
return this.type !== 'year' && this.type !== 'time' && this.type !== 'hour-minute';
},
isShowDay() {
return this.type === 'date' || this.type === 'datetime' || this.type === 'datetime-all';
},
hours() {
return this.initTimeData(23, 0);
},
isShowHour() {
return this.type !== 'date' && this.type !== 'year-month' && this.type !== 'year';
},
minutes() {
return this.initTimeData(59, 0);
},
isShowMinute() {
return this.type !== 'date' && this.type !== 'year-month' && this.type !== 'year';
},
seconds() {
return this.initTimeData(59, 0);
},
isShowSecond() {
return this.type === 'datetime-all' || this.type === 'time';
}
},
methods: {
getIndicatorStyle(){
if(this.indicatorStyle){
for(let key in this.indicatorStyle){
this.indicatorStyleString += `${key}:${this.indicatorStyle[key]};`
}
}
},
handleEvent() {
return;
},
cancel() {
this.hide();
},
confirm() {
this.formatDate();
this.hide();
},
show() {
this.visible = true;
},
hide() {
this.visible = false;
},
initDateTime() {
let value;
if (this.datestring.length > 0) {
if (this.type === 'year') {
value = new Date(this.datestring, 0);
} else if (this.type === 'time' || this.type === 'hour-minute') {
let date = new Date();
let ary = this.datestring.split(':');
ary.forEach((item, index) => {
if (index == 0) {
date.setHours(item)
} else if (index == 1) {
date.setMinutes(item)
} else if (index == 2) {
date.setSeconds(item)
}
})
value = date;
} else {
value = new Date(this.datestring.replace(/-/g, '/'));
}
} else {
value = new Date();
}
let len, timeArray, index;
let array = getTimeArray(value);
let [year, month, day, hour, minute, second] = array;
this.days = this.initTimeData(getOneMonthDays(year, month-1), 1);
let names = ['year', 'month', 'day', 'hour', 'minute', 'second'];
switch (this.type) {
case "date":
len = 3;
break;
case "year-month":
len = 2;
break;
case "year":
len = 1;
break;
case "datetime":
len = 5;
break;
case "datetime-all":
len = 6;
break;
case "time":
len = 3;
break;
case "hour-minute":
len = 2;
break;
}
timeArray = new Array(len).fill(0);
if (this.type === 'time' || this.type === 'hour-minute') {
names = names.slice(3);
array = array.slice(3);
}
timeArray = timeArray.map((item, index) => {
const name = names[index];
return getIndexOfArray(array[index], this[name + 's'])
})
this.dateTime = timeArray;
},
initTimeData(end, start) {
let timeArray = [];
while (start <= end) {
timeArray.push(start);
start++;
}
return timeArray;
},
formatDate() {
let names = ['year', 'month', 'day', 'hour', 'minute', 'second'];
let dateString, formatDateArray = [];
if (this.type === 'date' || this.type === 'year-month' || this.type === 'year') {
formatDateArray = this.dateTime.map((item, index) => {
return this[names[index] + 's'][item] < 10 ? addZero(this[names[index] + 's'][item]) : this[names[index] + 's'][item];
})
dateString = formatDateArray.join('-');
} else if (this.type === 'time' || this.type === 'hour-minute') {
names = names.splice(3);
formatDateArray = this.dateTime.map((item, index) => {
return this[names[index] + 's'][item] < 10 ? addZero(this[names[index] + 's'][item]) : this[names[index] + 's'][item];
})
dateString = formatDateArray.join(':');
} else {
let name1 = names.splice(0, 3);
formatDateArray = this.dateTime.map((item, index) => {
if (index > 2) {
return this[names[index - 3] + 's'][item] < 10 ? addZero(this[names[index - 3] + 's'][item]) : this[names[index - 3] + 's'][item];
} else {
return this[name1[index] + 's'][item] < 10 ? addZero(this[name1[index] + 's'][item]) : this[name1[index] + 's'][item];
}
})
dateString = formatDateArray.splice(0, 3).join('-') + ' ' + formatDateArray.join(':');
}
this.$emit('change', dateString)
},
dateTimePickerChange(e) {
let columns = e.target.value;
if (this.type === 'date' || this.type === 'datetime' || this.type === 'datetime-all') {
this.dateTime.splice(0, 1, columns[0]);
if (columns[0] != this.dateTime[0]) {
this.days = this.initTimeData(getOneMonthDays(this.years[this.dateTime[0]], this.months[this.dateTime[1]]), 1);
if (this.dateTime[1] == 1) {
if (this.dateTime[2] === this.days.length - 1) {
if (getOneMonthDays(this.years[columns[0]], this.dateTime[1]) < getOneMonthDays(this.years[this.dateTime[0]],this.dateTime[1])) {
this.dateTime.splice(2, 1, this.days.length - 1)
}
}
}
} else {
this.dateTime.splice(1, 1, columns[1]);
this.days = this.initTimeData(getOneMonthDays(this.years[this.dateTime[0]], this.dateTime[1]), 1);
if (columns[1] != this.dateTime[1]) {
if (this.dateTime[1] == 1) {
if (this.dateTime[2] === this.days.length - 1) {
if (getOneMonthDays(this.years[columns[0]], this.dateTime[1]) < getOneMonthDays(this.years[this.dateTime[0]],
this.dateTime[1])) {
this.dateTime.splice(2, 1, this.days.length - 1)
}
}
} else {
if (this.dateTime[2] > this.days.length - 1) {
this.dateTime.splice(2, 1, this.days.length - 1)
} else {
this.dateTime.splice(2, 1, columns[2])
}
}
} else {
this.dateTime.splice(2, 1, columns[2])
}
}
if (columns.length > 2) {
columns.splice(3).forEach((column, index) => {
this.dateTime.splice(index + 3, 1, column);
})
}
} else {
columns.forEach((column, index) => {
this.dateTime.splice(index, 1, column);
})
}
if (!this.isShowToolBar) {
this.formatDate();
}
},
},
mounted() {
this.getIndicatorStyle();
this.initDateTime();
}
}
</script>
<style lang='scss' scoped>
.date-time-picker {
.date-time-mask {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgba($color: #000000, $alpha: .5);
z-index: 998;
}
.date-time-container {
position: fixed;
height: 50%;
bottom: 0;
right: 0;
left: 0;
background-color: #f6f6f6;
z-index: 1000;
display: flex;
flex-direction: column;
.time-picker-tool {
height: 80rpx;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
.cancel-btn {
padding: 0 28rpx;
box-sizing: border-box;
color: #969799;
}
.tool-title {
font-weight: 500;
font-size: 16px;
max-width: 50%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.confirm-btn {
padding: 0 28rpx;
box-sizing: border-box;
color: #576b95;
}
}
.picker-view {
width: 100%;
flex: 1;
.item {
font-size: 34rpx;
display: flex;
align-items: center;
justify-content: center;
}
}
}
}
</style>
/**
* 获取某年某月有多少天
*/
export const getOneMonthDays = (year,month)=>{
month = Number(month);
const baseMonthsDays = [31,28,31,30,31,30,31,31,30,31,30,31];
if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)){
if(month === 1){
baseMonthsDays[month] = 29;
}
}
return baseMonthsDays[month];
}
/**
* 获取日期的年月日时分秒
*/
export const getTimeArray = (date)=>{
const year = date.getFullYear();
const month = date.getMonth()+1;
const day = date.getDate();
const hour = date.getHours();
const minute = date.getMinutes();
const second = date.getSeconds();
return [year,month,day,hour,minute,second];
}
/**
* 小于10的数字前面补0
*/
export const addZero = (num)=>{
return num < 10 ? '0' + num : num;
}
/**
* 获取当前值在数组中的索引
*/
export const getIndexOfArray = (value,array)=>{
let index = array.findIndex(item => item == value);
return index > -1 ? index : 0;
}
\ No newline at end of file
......@@ -395,8 +395,31 @@
"navigationBarTitleText": "物流发货",
"navigationBarBackgroundColor":"#FFFFFF"
}
},{
"path":"pages/publishActivities/activityList/activityList",
"style" : {
//机型列表
"navigationBarTitleText": "活动列表",
"navigationBarBackgroundColor":"#FFFFFF",
"enablePullDownRefresh":true
}
],
},{
"path":"pages/publishActivities/publishActivity/publishActivity",
"style" : {
//机型列表 activityDetail
"navigationBarTitleText": "发布免费活动",
"navigationBarBackgroundColor":"#FFFFFF"
}
},{
"path":"pages/publishActivities/activityDetail/activityDetail",
"style" : {
//机型列表 activityDetail
"navigationBarTitleText": "活动详情",
"navigationBarBackgroundColor":"#FFFFFF",
"enablePullDownRefresh":true
}
} ],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "",
......
......@@ -158,7 +158,6 @@
<view class="inputbox flex">
<picker mode="date" fields="day" :value="form.manufacture_date" @change="bindDateChange">
<input disabled="true" class="input flex1" type="text" v-model="form.manufacture_date" value="" placeholder-class="plclass" placeholder="请填写生产日期" />
<!-- <view class="uni-input">{{date}}</view> -->
</picker>
</view>
</view>
......
......@@ -310,6 +310,19 @@
</view>
</view>
</view>
<!-- url="/pages/publishActivities/activityList/activityList" -->
<view class="jiu_max ">
<navigator url="/pages/publishActivities/activityList/activityList">
<view class="jiu_min">
<view>
<image class="img" src="/static/icon/download.png" mode=""></image>
</view>
<view>0元领活动</view>
</view>
</navigator>
</view>
</view>
<view class="BH"></view>
......@@ -320,7 +333,8 @@
<script>
import {
getskipShop
getskipShop,
activity_nucleus
} from "@/utils/api/merchant.js";
import uniBadge from "@/components/uni/uni-badge/uni-badge.vue"
import uniIcon from "@/components/uni/uni-icon/uni-icon.vue"
......@@ -419,6 +433,19 @@
saoma(e) {
uni.scanCode({
success: res => {
if (res.scanType == 'QR_CODE') {
let param = this.GetRequest(res.result);
param.shop_id = this.shop_id
activity_nucleus(param).then(res => {
if (res.code == 0) {
this.$api.msg(res.msg);
}else{
this.$api.msg(res.msg);
}
})
return;
} else if (res.scanType == 'EAN_13') {
uni.request({
url: 'https://www.mxnzp.com/api/barcode/goods/details', //仅为示例,并非真实接口地址。
data: {
......@@ -429,7 +456,7 @@
},
method: 'GET',
success: (results) => {
console.log(results);
// console.log(results);
if (results.data.code == 0) {
// this.$api.msg(results.data.msg);
results.isScanCode = false;
......@@ -443,12 +470,12 @@
uni.navigateTo({
url: '/pages/addEditEleProduct/addEditEleProduct?results=' + JSON.stringify(results)
})
console.log(results)
// console.log(results)
}
},
fail: (results) => {
console.log(results);
// console.log(results);
results.isScanCode = false;
results.code = res.result;
uni.navigateTo({
......@@ -457,8 +484,34 @@
}
})
}
}
});
},
// 解析链接中的参数
/**
* 解析url地址的参数
* @param {string} urlStr
*/
GetRequest: (urlStr) => {
if (typeof urlStr == "undefined") {
var url = decodeURI(location.search); //获取url中"?"符后的字符串
} else {
var url = "?" + urlStr.split("?")[1];
}
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
}
}
return theRequest;
},
jump() {
uni.navigateTo({
url: '/pages/edit/pro_manage/pro_manage?money_type=' + this.money_type + '&' + 'activity_type=' + this.activity_type
......@@ -474,12 +527,12 @@
let that = this
uni.showModal({
title: '复制链接在电脑端浏览器打开',
content:`${that.$store.state.uploadurl}api/index/excel?shop_id=${this.shop_id}`,
content: `${that.$store.state.uploadurl}api/index/excel?shop_id=${that.shop_id}`,
confirmText: '复制',
success: function(res) {
if (res.confirm) {
uni.setClipboardData({
data: `${that.$store.state.uploadurl}api/index/excel?shop_id=${this.shop_id}`,
data: `${that.$store.state.uploadurl}api/index/excel?shop_id=${that.shop_id}`,
success: () => { //复制成功的回调函数
uni.showToast({ //提示
title: '复制成功'
......
<template>
<view>
<view class="">
<view class="" style="text-align: center;height: 120upx;line-height: 120upx;font-weight: bold;font-size: 32upx;">
以有 <text style="color: #21B94C;font-size: 60upx;">150</text>人领取 还剩50人未领取
</view>
</view>
<view class="" style="height: 160upx;padding: 0 24upx;background-color: rgb(255, 255, 255);margin-bottom: 20upx;" v-if="getDetail.length > 0 " v-for="(item,index) in getDetail">
<view class="fx " style="justify-content: space-between;background-color: #fff; align-items: center;
height: 100%">
<view class="fx" style="width: 75%;align-items: center;" >
<view style="height: 120upx;width: 120upx;border-radius: 120upx;text-align: center;line-height: 80upx;overflow: hidden;">
<image :src="item.face" style="display: inline;"></image>
</view>
<view style="margin:0 0 0 10upx;width: 75%;padding: 20upx 10upx;">
<view style="font: 34upx 微软雅黑;padding-bottom:10upx ;" class="oneline">{{item.nickname}}</view>
<view style="font-size:20upx;color:rgb(116, 113, 113);padding-top: 10upx;">{{item.verification_time}}</view>
</view>
</view>
<view style="width: 15%;height: 104upx;">
<!-- <text style="color:#DC143C;padding: 0 12upx;border-radius: 10upx;font-size: 32upx;">
</text> -->
<image src="/static/lingqu.png" mode="" style="width:100% ;height: 100%;display: inline;"></image>
</view>
<!-- 关注插槽 -->
<!-- <slot name="before"></slot> -->
</view>
<!-- <slot name="content"> </slot> -->
</view>
<view v-if="getDetail.length <= 0" style="text-align: center;width: 100%;height:1000upx;line-height: 1000upx;font-size: 50upx;color:#8C8C8C ;">
还没有人领取~~
</view>
</view>
</template>
<script>
import {
activity_user
} from '@/utils/api/merchant.js';
export default {
data(){
return {
shop_id:'',
activity_id:'',
getDetail:[],
page:1
}
},
onReachBottom() {
console.log('触底加载');
activity_user({
shop_id:this.shop_id,
activity_id:this.activity_id,
nucleus:1,
page:this.page
}).then(res=>{
if(res.code==0&&res.data.list.length>0){
this.page++
this.getDetail = res.data.list
uni.stopPullDownRefresh();
}else{
uni.$api.msg('没有更多数据了')
}
})
},
onPullDownRefresh() {
this.page = 1
activity_user({
shop_id:this.shop_id,
activity_id:this.activity_id,
nucleus:1
}).then(res=>{
if(res.code==0){
this.getDetail = res.data.list
uni.stopPullDownRefresh();
}
})
},
onLoad(options) {
let that = this
that.activity_id = options.activity_id
uni.getStorage({
key: 'userInfo',
success(res) {
that.shop_id = res.data.shop_id
}
})
activity_user({
shop_id:that.shop_id,
activity_id:that.activity_id,
nucleus:1
}).then(res=>{
if(res.code==0){
this.getDetail = res.data.list
}
})
},
}
</script>
<style>
page{
background-color: #EEEEEE;
}
.fx {
display: flex;
}
.guanzhu {
padding: 24upx;
border-top: 2upx solid #eee;
/* border-bottom: 1upx solid #eee; */
}
.pd24 {
padding: 24upx
}
</style>
<template>
<view class="">
<!-- tab切换 -->
<view class="projuctTab flex">
<view class="tabitems flex1" :class="{active:tabactive==1}" @tap="taggletab(1)">
<view class="tabtitle">开始活动</view>
<!-- ({{count[0]}}) -->
</view>
<view class="tabitems flex1" :class="{active:tabactive==2}" @tap="taggletab(2)">
<view class="tabtitle">过期活动</view>
<!-- ({{count[1]}}) -->
</view>
</view>
<view class="projuctlist" :hidden="!(tabactive==1)">
<view class="" v-if="start_activity.length>0">
<checkbox-group >
<!-- 单个商品 -->
<view class="itempro flex " v-for="(item,index) in start_activity" :key="index" @click="jumpDetail(item.activity_id)">
<!-- <label class="ali-c">
<checkbox :value="item.id.toString()" :checked="item.checked==true" />
</label> -->
<image class="thumbnail" :src="staticUrl + item.picture" mode=""></image>
<view class="infobox" style="width: 70%;">
<view class="title oneline" style="height:40upx ;">{{item.goods_name}}</view>
<!-- <view class="time">上架时间:{{item.create_time}}</view> -->
<view>
<view style="font-size:26rpx;font-weight:bold;">领取时间:</view>
<view style="font-size:24rpx;color:#656565">{{item.start}}{{item.end}}</view>
</view>
</view>
<view class="btnbox flex" >
<!-- <view class="btns btnboxdel" @tap="deleteEleProductfun(item,index)">删 除</view> -->
<!-- <view class="btns btnboxxj" @tap="Selectiondata(item)" v-if="tabactive==1 && isselect==1">加入活动</view> -->
<!-- <view class="btns btnboxxj" @tap="sold_outfun(item.id,1,index)" v-else-if="tabactive==1">下 架</view> -->
<!-- <view class="btns btnboxxj" @tap="sold_outfun(item.id,0,index)" v-show="tabactive==2">上 架</view> -->
<!-- <view class="btns btnboxxj" @click="setSpecs(item.product_id)" >规格</view> -->
<view >
<view class="btnboxdel flex" style="align-items: center;" @click.stop="switch1Change">
活动开关:<switch :data-activity_id="item.activity_id" :checked="item.state==1" @change="switch1Change" />
<view class="btns btnboxdel" @tap.stop="tochanges(item,index)">修 改</view>
</view>
</view>
</view>
</view>
</checkbox-group>
</view>
<view v-if="start_activity.length <= 0" style="text-align: center;width: 100%;height:1000upx;line-height: 1000upx;font-size: 50upx;color:#8C8C8C ;">
还没有人领取~~
</view>
</view>
<view class="projuctlist" :hidden="!(tabactive==2)">
<view class="" v-if="end_activity.length > 0">
<checkbox-group >
<!-- 单个商品 -->
<view class="itempro flex " v-for="(item,index) in end_activity" :key="index" @click="jumpDetail(item.activity_id)">
<!-- <label class="ali-c">
<checkbox :value="item.id.toString()" :checked="item.checked==true" />
</label> -->
<image class="thumbnail" :src="staticUrl + item.picture" mode=""></image>
<view class="infobox" style="width: 70%;">
<view class="title oneline">{{item.goods_name}}</view>
<!-- <view class="time">上架时间:{{item.create_time}}</view> -->
<view>
<view style="font-size:26rpx;font-weight:bold;">领取时间:</view>
<view style="font-size:24rpx;color:#656565">{{item.start}}{{item.end}}</view>
</view>
</view>
<view class="btnbox flex">
<!-- <view class="btns btnboxdel" @tap="deleteEleProductfun(item,index)">删 除</view> -->
<!-- <view class="btns btnboxxj" @tap="Selectiondata(item)" v-if="tabactive==1 && isselect==1">加入活动</view> -->
<!-- <view class="btns btnboxxj" @tap="sold_outfun(item.id,1,index)" v-else-if="tabactive==1">下 架</view> -->
<!-- <view class="btns btnboxxj" @tap="sold_outfun(item.id,0,index)" v-show="tabactive==2">上 架</view> -->
<!-- <view class="btns btnboxxj" @click="setSpecs(item.product_id)" >规格</view> -->
<!-- <view class="btnboxdel">
活动开关:<switch :checked="chdecked" @change="switch1Change" />
</view>
<view class="btns btnboxdel" @tap="tochanges(item,index)">修 改</view> -->
</view>
</view>
</checkbox-group>
</view>
<view v-if="end_activity.length <= 0" style="text-align: center;width: 100%;height:1000upx;line-height: 1000upx;font-size: 50upx;color:#8C8C8C ;">
还没有人领取~~
</view>
</view>
<view class="footchindbox flex ali-c jus-b">
<navigator url="/pages/publishActivities/publishActivity/publishActivity" class="submitbtns">发布活动</navigator>
</view>
</view>
</template>
<script>
import {
activity_select,
activity_close
} from '@/utils/api/merchant.js';
export default {
data() {
return {
tabactive: 1,
page: 0,
start_activity: [],
end_activity: [],
endpages:0,
startpages:0
}
},
computed: {
staticUrl() { //静态资源地址
return this.$store.state.staticUrl;
}
},
onLoad() {
console.log('onl;oafdas')
let that = this
uni.getStorage({
key: 'userInfo',
success(res) {
that.shop_id = res.data.shop_id
}
})
},
//下拉刷新
onPullDownRefresh(){
if(this.tabactive == 1){
this.startpages = 0
activity_select({
shop_id: this.shop_id,
page: 0,
is_date: 2
}).then(res => {
if (res.code == 0) {
this.start_activity = res.data.data
uni.stopPullDownRefresh();
}
})
}else if(this.tabactive == 2){
this.endpages = 0
activity_select({
shop_id: this.shop_id,
page: 0,
is_date: 1
}).then(res => {
if (res.code == 0) {
this.end_activity = res.data.data
uni.stopPullDownRefresh();
}
})
}
},
//上拉触底
onReachBottom(){
if (this.tabactive == 1) {
activity_select({
shop_id: this.shop_id,
page: ++this.startpages,
is_date: 2
}).then(res => {
if (res.code == 0) {
this.start_activity = [...this.start_activity,...res.data.data]
}
})
} else if (this.tabactive == 2) {
activity_select({
shop_id: this.shop_id,
page: ++this.endpages,
is_date: 1
}).then(res => {
if (res.code == 0) {
this.end_activity = [...this.this.end_activity,...res.data.data]
}
})
}
},
onShow() {
this.endpages = 0
this.startpages = 0
if (this.tabactive == 1) {
activity_select({
shop_id: this.shop_id,
page: 0,
is_date: 2
}).then(res => {
if (res.code == 0) {
this.start_activity = res.data.data
}
})
} else if (this.tabactive == 2) {
activity_select({
shop_id: this.shop_id,
page: 0,
is_date: 1
}).then(res => {
if (res.code == 0) {
this.end_activity = res.data.data
}
})
}
},
methods: {
jumpDetail(activity_id){
uni.navigateTo({
url:`/pages/publishActivities/activityDetail/activityDetail?activity_id=${activity_id}`
})
},
//修改活动
tochanges(data, index) {
uni.navigateTo({
url: `/pages/publishActivities/publishActivity/publishActivity?id=${data.activity_id}&type=edit`,
})
},
// 查找产品
findEleProduct(){
},
switch1Change(e) {
if(e.type=='change'){
console.log(e)
if (e.detail.value) {
activity_close({
shop_id: this.shop_id,
activity_id: e.currentTarget.dataset.activity_id,
state: 1
}).then(res => {
if (res.code == 0) {
this.$api.msg('活动开启')
}
})
} else {
activity_close({
shop_id: this.shop_id,
activity_id: e.currentTarget.dataset.activity_id,
state: 2
}).then(res => {
if (res.code == 0) {
this.$api.msg('活动关闭')
}
})
}
}else{
return ;
}
},
//交互end
taggletab(index) {
this.tabactive = index;
if (index == 1) {
if (this.start_activity.length == 0) {
activity_select({
shop_id: this.shop_id,
page: 0,
is_date: 2
}).then(res => {
if (res.code == 0) {
this.start_activity = res.data.data
}
})
} else {
return;
}
} else if (index == 2) {
if (this.end_activity.length == 0) {
activity_select({
shop_id: this.shop_id,
page: 0,
is_date: 1
}).then(res => {
if (res.code == 0) {
this.end_activity = res.data.data
}
})
} else {
return;
}
}
},
}
}
</script>
<style lang="scss">
.projuctlist {
margin: 130upx 24upx;
padding-top: 18upx;
background: rgba(255, 255, 255, 1);
border-radius: 14upx;
.itempro {
position: relative;
border-bottom: 1px solid rgba(220, 220, 220, 1);
padding: 20upx;
.thumbnail {
width: 170upx;
height: 170upx;
border-radius: 6upx;
margin-right: 27upx;
margin-left: 20upx;
}
.infobox {
.title {
font-size: 34upx;
color: rgba(51, 51, 51, 1);
//margin-bottom: 5upx;
}
.time {
//margin-bottom: 5upx;
}
.time,
.price {
font-size: 30upx;
color: rgba(153, 153, 153, 1);
}
}
.btnbox {
position: absolute;
bottom: 5px;
right: 5px;
.btns {
width: 100upx;
height: 60upx;
line-height: 60upx;
text-align: center;
border: 1upx solid rgba(160, 160, 160, 1);
border-radius: 4upx;
font-size: 30upx;
color: rgba(0, 0, 0, 1);
}
.btnboxdel {
margin-left: 16upx;
}
.btnboxxj {
background: #FF6900;
color: #FFFFFF;
border: 0;
margin-left: 16upx;
}
}
}
}
.projuctTab {
background: #FFFFFF;
width: 100%;
height: 98upx;
line-height: 98upx;
position: fixed;
top: 0;
/* #ifdef H5 */
top: 86upx;
/* #endif */
left: 0;
z-index: 99;
.tabitems {
text-align: center;
.tabtitle {
text-align: center;
height: 98upx;
line-height: 98upx;
font-size: 30upx;
display: inline-block;
box-sizing: border-box;
color: #333333;
}
}
.tabitems.active {
.tabtitle {
font-family: PingFang SC;
font-weight: bold;
color: #FF6900;
border-bottom: 1px solid #FF6900;
}
}
}
.footchindbox {
width: 100%;
height: 117upx;
background: rgba(255, 255, 255, 1);
padding: 16upx 24upx;
position: fixed;
bottom: 0;
left: 0;
.rightbtn {
.btns {
width: 163upx;
height: 84upx;
line-height: 84upx;
text-align: center;
border: 1px solid rgba(160, 160, 160, 1);
border-radius: 6upx;
color: #000000;
font-size: 35upx;
}
.btns1 {}
.btns2 {
margin-left: 28upx;
background: rgba(255, 102, 0, 1);
color: #FFFFFF;
border: 0;
}
}
}
.submitbtns {
background: #FF6900;
height: 88upx;
line-height: 88upx;
color: #FFFFFF;
text-align: center;
width: 100%;
border-radius: 14upx;
}
</style>
<template>
<view class="productpages" style="margin-top: 20upx;">
<view class="boxcss" style="padding: 30upx">
<view class="littleTitle">
<text>活动时间</text>
</view>
<view class="flex">
<view class="" style="flex:4;text-align: center;margin: auto;background-color:#F0F0F0;height: 60upx;padding: 6upx;" @click="bindDateStartChange(1)">
<input disabled class="inputs" type="text" v-model="form.start_time" placeholder="选择开始时间"/>
</view>
<view class="" style="flex:2;text-align: center;margin: auto;background-color:#fff;height: 60upx;"></view>
<view class="" style="flex:4;text-align: center;margin: auto;background-color:#F0F0F0; height: 60upx;padding: 7upx;" @click="bindDateStartChange(2)">
<input disabled class="inputs" type="text" v-model="form.end_time" placeholder="选择结束时间" />
</view>
</view>
</view>
<view class="boxcss" style="padding: 30upx">
<view class="littleTitle">
<text>填写产品标题</text>
</view>
<view>
<view class="" style="background-color:#F0F0F0;height: 60upx;padding: 6upx;">
<input class="inputs" type="text" v-model="form.title" placeholder="请填写产品标题" />
</view>
</view>
</view>
<view class="boxcss" style="padding: 30upx">
<view class="littleTitle">
<text>分享标题标题</text>
</view>
<view>
<view class="" style="background-color:#F0F0F0;height: 60upx;padding: 6upx;">
<input class="inputs" type="text" v-model="form.share_title" placeholder="分享标题标题" />
</view>
</view>
</view>
<view class="boxcss" style="padding: 30upx">
<view class="littleTitle">
<text>请填写产品领取总份数</text>
</view>
<view>
<view class="" style="background-color:#F0F0F0;height: 60upx;padding: 6upx;">
<input class="inputs" type="number" v-model="form.limit_stock" placeholder="请填写产品领取总份数" />
</view>
</view>
</view>
<view class="boxcss" style="padding: 30upx">
<view class="littleTitle">
<text>填写产品限购购数</text>
</view>
<view>
<view class="" style="background-color:#F0F0F0;height: 60upx;padding: 6upx;">
<input class="inputs" type="number" v-model="form.limit_get" placeholder="请填写产品领取总份数" />
</view>
</view>
</view>
<view style="background-color:#fff;margin:2rpx 0 10rpx 0;padding: 30upx" >
<view style="font-size:30rpx ;font-weight: bold; padding:24rpx 0 60rpx 24rpx;">添加一张分享图</view>
<view style="padding:0 0 24rpx 24rpx;display:flex;flex-wrap:wrap;">
<!-- -->
<view style="height:160rpx;width:160rpx;margin: 0 20rpx 20rpx 0;" v-for=" (item,index) in sharepictureArr">
<image :src="staticUrl + item" style="display: inline;" @click="showshareImg(index)"></image>
<view @click="clearshareImg(index)" style="width: 30rpx;height: 30rpx;background-color: black; color: #fff;line-height: 30rpx;text-align: center;position: relative;border-radius: 30rpx;left: 140rpx;top:-170rpx">
<text>×</text>
</view>
</view>
<view :hidden="!shareshowUpload" style="padding: 1rpx;height:160rpx;width:160rpx" @tap="uploadshareImg">
<image style="display: inline;" src="https://luma.jxdsy.cn/static/applet5/images/slices/addimage.png"></image>
</view>
</view>
</view>
<view style="background-color:#fff;margin:2rpx 0 10rpx 0;padding: 30upx" >
<view style="font-size:30rpx ;font-weight: bold; padding:24rpx 0 60rpx 24rpx;">添加图片</view>
<view style="padding:0 0 24rpx 24rpx;display:flex;flex-wrap:wrap;">
<!-- -->
<view style="height:160rpx;width:160rpx;margin: 0 20rpx 20rpx 0;" v-for=" (item,index) in pictureArr">
<image :src="staticUrl + item" style="display: inline;" @click="showImg(index)"></image>
<view @click="clearImg(index)" style="width: 30rpx;height: 30rpx;background-color: black; color: #fff;line-height: 30rpx;text-align: center;position: relative;border-radius: 30rpx;left: 140rpx;top:-170rpx">
<text>×</text>
</view>
</view>
<!-- 服务器 -->
<!-- <view style="height:160rpx;width:160rpx;margin: 0 20rpx 20rpx 0;" v-for=" (item,index) in uploaderList">
<image :src="item" style="display: inline;" @click="showImg(index)"></image>
<view @click="clearImg(index)" style="width: 30rpx;height: 30rpx;background-color: black; color: #fff;line-height: 30rpx;text-align: center;position: relative;border-radius: 30rpx;left: 140rpx;top:-170rpx">
<text>×</text>
</view>
</view> -->
<view :hidden="!showUpload" style="padding: 1rpx;height:160rpx;width:160rpx" @tap="uploadImg">
<image style="display: inline;" src="https://luma.jxdsy.cn/static/applet5/images/slices/addimage.png"></image>
</view>
</view>
</view>
<view style="text-align:center;height:300upx;background-color: #EEEEEE;">
<button style="top: 35%;width:300upx;color:#fff;background-color: #21B94C;" @tap="publishActivity(publishtype)">确定发布</button>
</view>
<borydateTimePicker
ref='dateTime'
type='datetime'
:datestring='dateString'
@change='dateTimeChange'>
</borydateTimePicker>
</view>
</template>
<script>
import borydateTimePicker from '@/components/bory-dateTimePicker/bory-dateTimePicker.vue'; //时间弹窗
import{activity_add,activity_find,activity_update} from "@/utils/api/merchant.js";
export default {
components:{
borydateTimePicker
},
data() {
return {
shareuploaderList:[],
sharejoinString: '',//上传图片字符
shareimagesrc: '', //上传时后端返回的图片ID,拼接后存入
shareuploaderList: [], //保存上传图片url的数组
shareuploaderNum: 0, //已经上传的图片数目
shareshowUpload: true, //控制上传框的显隐
sharepictureArr: [],//存放上传图片地址
publishopen:true,
publishtype:'',
dateString:'',
joinString: '',//上传图片字符
imagesrc: '', //上传时后端返回的图片ID,拼接后存入
uploaderList: [], //保存上传图片url的数组
uploaderNum: 0, //已经上传的图片数目
showUpload: true, //控制上传框的显隐
pictureArr: [],//存放上传图片地址
publishContent: "", //评论内容
goods_id: '', //商品id
goods_title: '',
is_open:1,
form: {
start_time: '',
end_time: '',
title:'',
limit_stock:'',
limit_get:'',
shop_id:'',
share_title:''
},
}
},
computed: {
staticUrl() {
// https://luma.jxdsy.cn/api/File_upload/uploadify
//静态资源地址
return this.$store.state.staticUrl;
},
staticUrl1() {
return this.$store.state.staticUrl1;
},
},
onLoad(options) {
let that = this
this.activity_id = options.id
this.publishtype = options.type
// console.log(options)
uni.getStorage({
key:'userInfo',
success(res) {
console.log(res)
that.form.shop_id=res.data.shop_id
}
})
if(this.publishtype == 'edit'){
this.activity_find(options.id);
}
},
onShow() {
},
methods: {
/**
* 查询产品
*/
activity_find(activity_id){
console.log('修改')
activity_find({
shop_id:this.$data.shop_id,
activity_id:activity_id
}).then(res=>{
if(res.code == 0){
this.form.start_time = res.data.data.start,
this.form.end_time = res.data.data.end,
this.form.title = res.data.data.goods_name,
this.form.limit_stock = res.data.data.limit_stock,
this.form.limit_get = res.data.data.limit_get,
this.pictureArr = res.data.data.picture,
this.form.share_title = res.data.data.share_title,
this.sharepictureArr[0] = res.data.data.share_pictures
console.log(this.share_title)
if(this.sharepictureArr[0]){
this.shareshowUpload = false
}
if(this.pictureArr.length == 3){
this.showUpload = false
}
}
})
},
publishActivity(e) {
if((!this.form.start_time) || (!this.form.end_time)){
this.$api.msg('开始或结束时间未选择')
return false;
}
if(new Date(this.form.end_time).getTime() <= new Date(this.form.start_time).getTime()){
this.$api.msg('活动开始时间不可以大于结束时间')
return false;
}
if(this.form.title==''){
this.$api.msg('没有填写活动标题')
return false;
}
if(this.form.limit_stock==''){
this.$api.msg('没有填写领取总份数')
return false;
}
if(this.form.share_title==''){
this.$api.msg('没有填写分享标题')
return false;
}
if(this.form.limit_get==''){
this.$api.msg('没有填写限购购数')
return false;
}
if(this.pictureArr.length==0){
this.$api.msg('没有上传图片')
return false;
}
if(this.sharepictureArr.length==0){
this.$api.msg('没有上传分享图')
return false;
}
let picString = '';
for (let index = 0; index < this.pictureArr.length; index++) {
// console.log(this.pictureArr[index])
picString = picString + this.pictureArr[index] + ','
}
picString=picString.slice(0,picString.length-1)
let param = {
start:this.form.start_time, //开始时间
end : this.form.end_time, // 结束时间
limit_stock: this.form.limit_stock,// 领取数量
limit_get:this.form.limit_get, //限购购数
shop_id: this.form.shop_id,// 商家id
goods_name:this.form.title , //商品名称
picture: picString, //商品图片字符串逗哈分割
share_pictures:this.sharepictureArr[0],
share_title:this.form.share_title
}
console.log(this.publishtype , 125215154)
if(this.publishtype == 'edit'){
param.activity_id = this.activity_id
activity_update(param).then(res=>{
if(res.code == 0){
this.$api.msg(res.msg);
setTimeout(()=>{
uni.navigateBack()
},1000)
}
})
}else{
console.log(this.publishopen)
if(this.publishopen){
this.publishopen = false;
console.log(this.publishopen)
activity_add(param).then(res=>{
if(res.code == 0){
this.$api.msg(res.msg);
setTimeout(()=>{
this.publishopen= true;
uni.navigateBack()
},1000)
}
})
}else{
this.$api.msg('不要连续点击')
}
}
},
bindDateStartChange(e) {
this.is_open = e
console.log(e)
this.$refs.dateTime.show()
},
dateTimeChange(dataTime){
if(this.is_open == 1){
this.form.start_time = dataTime
}else if(this.is_open == 2){
this.form.end_time = dataTime
}
},
uploadshareImg:function(e){
let that = this;
uni.chooseImage({
count: 1 - that.shareuploaderNum, // 默认6
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function(res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
that.shareuploaderList.concat(res.tempFilePaths);
let uploaderList = res.tempFilePaths;
// console.log(uploaderList);
uni.showLoading({
title: '图片上传中'
});
that.shareuploaderList = that.shareuploaderList.concat(res.tempFilePaths)
that.shareuploaderNum = that.shareuploaderList.length
let host_url = 'https://luma.jxdsy.cn/api/File_upload/uploadify';
for (let i = 0; i < uploaderList.length; i++) {
uni.uploadFile({
url: host_url,
filePath: uploaderList[i],
name: 'files',
formData: {
files: uploaderList,
},
success: function(res) {
// console.log(res)
let json = res.data;
json = json.replace(/\ufeff/g, "");
let data = JSON.parse(json);
// console.log(data)
that.shareimagesrc = data.data
that.sharepictureArr.push(that.shareimagesrc)
uni.hideLoading()
if (that.sharepictureArr.length == 1) {
that.shareshowUpload = false
}
}
})
// console.log(that.pictureArr)
}
}
})
},
//上传图片
uploadImg: function(e) {
let that = this;
uni.chooseImage({
count: 3 - that.uploaderNum, // 默认6
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function(res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
that.uploaderList.concat(res.tempFilePaths);
let uploaderList = res.tempFilePaths;
// console.log(uploaderList);
uni.showLoading({
title: '图片上传中'
});
that.uploaderList = that.uploaderList.concat(res.tempFilePaths)
that.uploaderNum = that.uploaderList.length
let host_url = 'https://luma.jxdsy.cn/api/File_upload/uploadify';
for (let i = 0; i < uploaderList.length; i++) {
uni.uploadFile({
url: host_url,
filePath: uploaderList[i],
name: 'files',
formData: {
files: uploaderList,
},
success: function(res) {
// console.log(res)
let json = res.data;
json = json.replace(/\ufeff/g, "");
let data = JSON.parse(json);
// console.log(data)
that.imagesrc = data.data
that.pictureArr.push(that.imagesrc)
uni.hideLoading()
if (that.pictureArr.length == 3) {
that.showUpload = false
}
}
})
// console.log(that.pictureArr)
}
}
})
},
// 删除图片
clearImg: function (index) {
var that = this
// var nowList = []; //新数据
// var pictureArr = that.pictureArr; //原数据
that.pictureArr.splice(index,1);
that.uploaderNum = that.uploaderNum - 1
// uploaderList: nowList,
that.showUpload= true
},
// 删除图片
clearshareImg: function (index) {
var that = this
// var nowList = []; //新数据
// var pictureArr = that.pictureArr; //原数据
that.sharepictureArr.splice(index,1);
that.shareuploaderNum = that.shareuploaderNum - 1
// uploaderList: nowList,
that.shareshowUpload= true
},
showImg(index){
var imgArr = this.pictureArr.map((value, index) => {
return "https://luma.jxdsy.cn/attachs/" + value
})
let url = imgArr[index]
uni.previewImage({
current: url,
urls: imgArr,
})
},
showshareImg(index){
var imgArr = this.sharepictureArr.map((value, index) => {
return "https://luma.jxdsy.cn/attachs/" + value
})
let url = imgArr[index]
uni.previewImage({
current: url,
urls: imgArr,
})
}
// }
}
}
</script>
<style>
.productpages {
background: #FFFFFF;
/* padding: 30upx; */
width: 100%;
}
.inputs {
border: ;
}
.showUpload {
display: none;
}
.littleTitle {
font-size: 30upx;
font-weight: bold;
padding: 20upx 0;
}
.boxcss{
padding: 20upx 0 ;
}
</style>
......@@ -47,6 +47,60 @@ export function getshopclass(data){
}
/**
* @param {Object} data
*/
//获取分类 列表
export function activity_nucleus(data){
return request.post("/ele/activity_nucleus", data, { noAuth: true});
}
/**
* 添加免费领东西活动
* @param {Object} data
*/
export function activity_add(data){
return request.post("/ele/activity_add", data, { noAuth: true});
}
/**
* 获取活动列表
* @param {Object} data
*/
export function activity_select(data){
return request.post("/ele/activity_select", data, { noAuth: true});
}
/**
* 关闭活动
* @param {Object} data
*/
export function activity_close(data){
return request.post("/ele/activity_close", data, { noAuth: true});
}
/**
* 活动详情
* @param {} data
*/
export function activity_find(data){
return request.post("/ele/activity_find", data, { noAuth: true});
}
/**
*
* @param {} data
*/
export function activity_user(data){
return request.post("/ele/activity_user", data, { noAuth: true});
}
/**
* 修改活动
* @param {} data
*/
export function activity_update(data){
return request.post("/ele/activity_update", data, { noAuth: true});
}
\ No newline at end of file
......@@ -5,9 +5,9 @@ module.exports = {
isdebug:false,//正式
// isdebug:false,//正式
// isdebug:true,//测试
isdebug:true,//测试
xqdebug:false,//正式权限
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment