This commit is contained in:
faiz 2024-05-19 11:52:22 +08:00
parent a293629c81
commit ed4b7c88a1
53 changed files with 522 additions and 72 deletions

View File

@ -40,7 +40,7 @@
</template>
<script>
import {} from '@/api/user.js'
import {setBlind} from '@/api/user.js'
export default {
components: {
},
@ -69,14 +69,24 @@
this.init()
},
methods: {
openBlindBox(val){
async openBlindBox(val){
this.actionIndex=val;
if(val/2){
setTimeout(()=>{
this.blind=false;
this.popShow=true;
},800)
await setBlind().then(res=>{
if(res.status == 200){
setTimeout(()=>{
this.popShow=true;
this.drawInfo.text = res.data.integral;
this.blind=!!res.data.integral;
},1500)
}else{
return this.$util.Tips({title:err})
}
}).catch(err=>{
// this.close();
// return this.$util.Tips({title:err})
});
}else{
setTimeout(()=>{
this.popShow=true;
@ -90,6 +100,7 @@
closePop(){
this.popShow=false;
this.blindShow=false;
this.$emit('cloneblindBox')
}
}
}

View File

@ -30,12 +30,13 @@
<image src="https://store.tropjoin.com/images/notBlind.png" style="width: 80px;height: 80px;" mode=""></image>
<view class="text-black">很遗憾,差一点就中奖了</view>
<view class="text-red">期待您下次再来</view>
<view class="btn" @click="confirm">我知道了</view>
<view class="btn" @click="confirm" v-if="!drawInfo.wheel">我知道了</view>
<view class="btn" @click="goBlind" v-else>继续开盲盒</view>
</view>
</view>
</view>
<blindBox v-if="blindShow"></blindBox>
<blindBox v-if="blindShow" @cloneblindBox='close'></blindBox>
</view>
</template>
@ -72,7 +73,7 @@
this.close();
},
async openBox(){
await setBlind().then(res=>{
await setSignIntegral().then(res=>{
this.drawInfo.text = res.data.integral;
this.drawInfo.wheel=res.data.wheel;
this.gifShow=true;

View File

@ -4,6 +4,7 @@ import App from './App'
import store from './store'
import Cache from './utils/cache'
import util from 'utils/util'
import fq from 'utils/fq'
import { HTTP_REQUEST_URL } from '@/config/app';
import skeleton from './components/skeleton/index.vue'
import BaseMoney from './components/BaseMoney.vue';
@ -12,6 +13,7 @@ Vue.component('skeleton', skeleton)
Vue.component('BaseMoney', BaseMoney)
Vue.prototype.$util = util;
Vue.prototype.$Cache = Cache;
Vue.prototype.$fq = fq;
Vue.prototype.$eventHub = new Vue();
Vue.config.productionTip = false
// Vue.use(uvUI);

View File

@ -2,8 +2,8 @@
"name" : "铸源商城",
"appid" : "__UNI__496DF55",
"description" : "",
"versionName" : "1.0.2",
"versionCode" : 129,
"versionName" : "1.0.3",
"versionCode" : 130,
"transformPx" : false,
/* 5+App */
"app-plus" : {

View File

@ -52,7 +52,7 @@
</view>
</view>
<view v-if="storeInfo.atmosphere_pic" class='integral_count skeleton-rect'>
<text v-if="storeInfo.max_integral > 0" class='integral'>铸源星最高可抵扣{{storeInfo.max_integral}}</text>
<!-- <text v-if="storeInfo.max_integral > 0" class='integral'>铸源星最高可抵扣{{storeInfo.max_integral}}</text> -->
<text v-if="storeInfo.delivery_free == 1" class='integral'>包邮</text>
</view>
<!--无氛围图-->
@ -94,7 +94,7 @@
</navigator>
</view>
<view v-if="!storeInfo.atmosphere_pic" class='integral_count skeleton-rect'>
<text v-if="storeInfo.max_integral > 0" class='integral'>铸源星最高可抵扣{{storeInfo.max_integral}}</text>
<!-- <text v-if="storeInfo.max_integral > 0" class='integral'>铸源星最高可抵扣{{storeInfo.max_integral}}</text> -->
<text v-if="storeInfo.delivery_free == 1" class='integral'>包邮</text>
</view>
<view v-if="!storeInfo.atmosphere_pic" class='introduce skeleton-rect'>
@ -1789,8 +1789,9 @@
.discount{
display: inline-block;
margin-left: 20rpx;
line-height: 60rpx;
min-height: 60rpx;
margin-top: 10rpx;
line-height: 40rpx;
min-height: 40rpx;
vertical-align: top;
border: 1px solid #F8D2CB;
padding-left: 20rpx;

View File

@ -21,12 +21,12 @@
<view>兑换方式</view>
<view class='itemCom'>铸源星兑换</view>
</view>
<view v-else class='item acea-row row-between-wrapper'>
<!-- <view v-else class='item acea-row row-between-wrapper'>
<view>支付方式</view>
<view v-if="order_pay_info.pay_type==1 || order_pay_info.pay_type==2 || order_pay_info.pay_type==3" class='itemCom'>微信</view>
<view v-else-if="order_pay_info.pay_type==4 || order_pay_info.pay_type==5" class='itemCom'>支付宝</view>
<view v-else class='itemCom'>余额</view>
</view>
</view> -->
<view v-if="order_type== 20" class='item acea-row row-between-wrapper'>
<view>支付铸源星</view>
<view class='itemCom'>{{order_pay_info.integral}}</view>

View File

@ -64,9 +64,9 @@
<view :class="{ active: diyActive ===2 }" class="item" @click="set_where(5,2)">
<view class="cont">活动</view>
</view>
<view :class="{ active: diyActive == 3 }" class="item" @click="getCoupon">
<!-- <view :class="{ active: diyActive == 3 }" class="item" @click="getCoupon">
<view class="cont">领券</view>
</view>
</view> -->
</view>
</view>
<scroll-view class="main" scroll-y="true" @scroll="scrollHome" catchtouchmove :style="viewColor">
@ -152,9 +152,9 @@
<view :class="{ active: diyActive == 2 }" class="item" @click="set_where(5,2)">
<view class="cont">活动</view>
</view>
<view :class="{ active: diyActive == 3 }" class="item" @click="getCoupon">
<!-- <view :class="{ active: diyActive == 3 }" class="item" @click="getCoupon">
<view class="cont">领券</view>
</view>
</view> -->
</view>
<view v-show="select.show && !navShow" class="select">
<view v-for="item in select.options" :key="item.id" :class="{ active: item.id === select.selected }" class="item"
@ -168,7 +168,7 @@
<view v-show="diyActive == 0 && tabActive == 1">
<!-- #ifdef H5 -->
<view v-for="(item, index) in styleConfig" :key="index">
<block v-if="item.name != 'headerSerch' && item.name != 'tabNav'">
<block v-if="item.name != 'headerSerch' && item.name != 'tabNav' && item.name != 'pageFoot'">
<component
:is="item.name"
:index="index"
@ -535,11 +535,11 @@
name: '分类',
value: 2,
},
{
icon: 'icon-liwu_o',
name: '专场',
value: 4,
}
// {
// icon: 'icon-liwu_o',
// name: '',
// value: 4,
// }
],
//
tabs2: [{
@ -557,11 +557,11 @@
name: '分类',
value: 2,
},
{
icon: 'icon-zhuanti',
name: '专场',
value: 4,
}
// {
// icon: 'icon-zhuanti',
// name: '',
// value: 4,
// }
],
tabs: [],
storeScroll: true,
@ -635,7 +635,7 @@
this.type = parseInt(options.type) || 1
this.id = options.mer_id || options.id || 0;
this.isCoupon = options.coupon || 0;
this.diyActive = options.order || 0;
this.diyActive = options.order || 1;
this.order = options.order;
this.preview = options.time ? true : false;
if (options.spid) {

View File

@ -106,7 +106,7 @@
<view class="iconfont icon-xiaoxi"></view>
<text class="iconnum" v-if="userInfo.total_unread">{{userInfo.total_unread}}</text>
</view>
<view class="iconfont icon-saoma" @tap='handleBorcode'></view>
<!-- <view class="iconfont icon-saoma" @tap='handleBorcode'></view> -->
</view>
</view>
</view>

View File

@ -554,7 +554,7 @@
"icon": "icon-weixin2",
value: 'weixin',
title: '微信快捷支付',
payStatus: 1,
payStatus: 2,
},
{
name: "支付宝支付",
@ -575,6 +575,13 @@
title: '可用余额:',
payStatus: this.$store.getters.globalData.yue_pay_status,
},
{
"name": "银联扫码",
"icon": "icon-icon-test",
value: 'sand',
title: '银联扫码',
payStatus: this.$store.getters.globalData.sand_open,
},
{
"name": "铸源星支付",
"icon": "haiyuefont haiyue-jifenduihuan",
@ -611,7 +618,7 @@
check:false
}
],
payType: 'weixin', //
payType: '', //
openType: 1, // 1=使
active: 0, //
coupon: {
@ -1256,6 +1263,7 @@
that.active = active;
that.animated = true;
that.payType = that.cartArr[active].value;
console.log(that.payType);
if (that.payType == 'weixin') {
that.payType = that.from
}
@ -1316,8 +1324,8 @@
callback_key = res.data.result.pay_key,
jsConfig = res.data.result.config,
goPages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=' + res.message;
that.orderPay = true;
that.orderPay = true;
console.log(status)
uni.hideLoading();
switch (status) {
case 'ORDER_EXIST':
@ -1492,8 +1500,22 @@
location.href = locations;
}, 100);
break;
case 'sand':
setTimeout(() => {
location.href = jsConfig;
}, 100);
break;
// #endif
// #ifdef APP-PLUS
case 'sand':
console.log(jsConfig);
if (plus.os.name === 'iOS') {
plus.runtime.openURL(jsConfig);
} else if (plus.os.name === 'Android') {
console.log(jsConfig);
plus.runtime.openURL(jsConfig);
}
break;
case 'alipayApp':
uni.requestPayment({
provider: 'alipay',

View File

@ -1,7 +1,7 @@
<template>
<view class="user_about" :style="viewColor">
<view>
<view class="text cancelTxt" :class="{cancelTxt: type == 'the_cancellation_msg'}">
<view style="margin-bottom: 148rpx;" class="text cancelTxt" :class="{cancelTxt: type == 'the_cancellation_msg'}">
<jyf-parser :html="data.replace(/<br\/>/ig, '')" ref="article" :tag-style="tagStyle"></jyf-parser>
</view>
</view>
@ -9,7 +9,8 @@
<view class="checkbox" @click="setCheck">
<view v-if="!check" class="iconfont icon-weixuanzhong"></view>
<view v-else class="iconfont icon-xuanzhong1"></view>
<view>已阅读并同意<text class="font" @click.stop="toCancel">重要提醒</text></view>
<!-- <view>已阅读并同意<text class="font" @click.stop="toCancel">重要提醒</text></view> -->
<view>已阅读并同意</view>
</view>
<view class="btn" @click="cancelBtn">
申请注销

View File

@ -66,17 +66,18 @@
点击实名认证<text class="iconfont icon-xiangyou"></text>
</navigator>
<view class='input acea-row row-between-wrapper' v-else>
<input type='text' value='已实名' disabled='true' class='id'></input>
<input style="width: 500rpx;" type='text' :value='userInfo.real_name+" | "+userInfo.card_id' disabled='true' class='id'></input>
<text class='iconfont icon-suozi'></text>
</view>
</view>
<!-- <view class='item acea-row row-between-wrapper'>
<view>ID号</view>
<view class='item acea-row row-between-wrapper'>
<view>抵扣券余额</view>
<view class='input acea-row row-between-wrapper'>
<input type='text' :value='userInfo.uid' disabled='true' class='id'></input>
<input type='text' :value='userInfo.now_money' disabled='true' class='id'></input>
<text class='iconfont icon-suozi'></text>
</view>
</view> -->
</view>
<view class='item acea-row row-between-wrapper'>
<view>手机号码</view>
<navigator url="/pages/users/user_phone/index" hover-class="none" class="input" v-if="!userInfo.phone">

View File

@ -29,9 +29,9 @@
</view>
</view>
<view class='item acea-row row-between-wrapper'>
<view>ID号</view>
<view>身份证</view>
<view class='input acea-row row-between-wrapper'>
<input type='text' :value='userInfo.uid' disabled='true' class='id'></input>
<input type='text' :value='userInfo.card_id' disabled='true' class='id'></input>
<text class='iconfont icon-suozi'></text>
</view>
</view>

View File

@ -7,7 +7,7 @@
<view class='pictrue'><image :src='userInfo.avatar ? userInfo.avatar : "/static/images/f.png"'></image></view>
<view class='text'>
<view class='line1'>{{userInfo.nickname}}</view>
<view class='integral acea-row'><text>铸源星: {{userInfo.integral ? userInfo.integral : 0}}</text></view>
<view class='integral acea-row'><text>积分: {{userInfo.integral ? userInfo.integral : 0}}</text></view>
</view>
</view>
<navigator class='right acea-row row-middle' hover-class='none' url='/pages/users/user_sgin_list/index'>
@ -39,7 +39,7 @@
<view class='item'>{{signCount[3] || 0}}</view>
<view class='data'></view>
</view>
<view class='tip2'>据说连续签到第7天可获得超额铸源星一定要坚持签到哦~~~</view>
<view class='tip2'>据说连续签到第7天可获得超额积分一定要坚持签到哦~~~</view>
<view class='list3'>
<view class='item acea-row' v-for="(item,index) in signList" :key="index">
<view>
@ -53,11 +53,11 @@
</view>
<treasureBox v-if="treasureShow" @closeTreasureBox="closeBox"></treasureBox>
<view class='signTip acea-row row-center-wrapper' v-if="active" :class='active==true?"on":""'>
<view class='signTip acea-row row-center-wrapper' :class='active==true?"on":""'>
<view class='signTipLight loadingpic'></view>
<view class='signTipCon' :style="'background-image: url('+domain+'/static/diy/signSuccess'+keyColor+'.png)'">
<view class='state'>签到成功</view>
<view class='integral'>获得{{integral}}铸源星</view>
<view class='integral'>获得{{integral}}积分</view>
<view class='signTipBnt' @click='close'>好的</view>
</view>
</view>
@ -91,7 +91,7 @@
is_sign: false, //
disabled: false,
treasureShow:false,
blindShow:false
};
},
computed: mapGetters(['isLogin','viewColor','keyColor']),
@ -182,32 +182,30 @@
if (that.userInfo.is_day_sgin) return this.$util.Tips({title:'您今日已签到!'});
that.disabled = true;
// if(!that.userInfo.is_day_sgin&&that.sign_index==6){
// that.treasureShow=true;
// that.blindShow=true;
// }else{
setSignIntegral().then(res=>{
that.active = true;
that.integral = res.data.integral;
that.sign_index = (that.sign_index + 1) > that.signConfig.title.length ? 1 : that.sign_index + 1;
that.signCount = that.PrefixInteger(sum_sgin_day + 1, 4);
that.$set(that.userInfo,'is_sgin',true);
that.$set(that.userInfo,'integral',that.$util.$h.Add(that.userInfo.integral, res.data.integral));
}).catch(err=>{
that.disabled = false;
return this.$util.Tips({title:err})
});
// }
that.treasureShow=true;
// }
// setSignIntegral().then(res=>{
// // that.active = true;
// that.integral = res.data.integral;
// that.sign_index = (that.sign_index + 1) > that.signConfig.title.length ? 1 : that.sign_index + 1;
// that.signCount = that.PrefixInteger(sum_sgin_day + 1, 4);
// that.$set(that.userInfo,'is_sgin',true);
// that.$set(that.userInfo,'integral',that.$util.$h.Add(that.userInfo.integral, res.data.integral));
// }).catch(err=>{
// that.disabled = false;
// return this.$util.Tips({title:err})
// });
},
/**
* 关闭签到提示
*/
close:function(){
this.active = false;
let that = this
if(!that.userInfo.is_day_sgin&&that.sign_index==6){
that.treasureShow=true;
}
// this.getSignList();
// this.getUserInfo();
this.getSignList();
this.getUserInfo();
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
static/images/1353901.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 881 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 B

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
static/images/gagag.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

BIN
static/images/img_2.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB

BIN
static/images/img_3.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 KiB

BIN
static/images/img_4.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

BIN
static/images/img_5.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 716 B

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 305 B

123
utils/fq.js Normal file
View File

@ -0,0 +1,123 @@
export default {
//接口域名https://xxxxxx.com
// #ifdef MP-WEIXIN
apiUrl: "",
// #endif
// #ifdef H5
apiUrl: "",
// apiUrl: "https://saasapi.hijin.vip",
// #endif
//分页方法
pageDataFn(number, pageSize, data) {
//处于第几页 number
//保存每页数据的数组
let pagedata = [];
//pageSize 每页条数
//设置开始
let start = (pageSize * number) - pageSize;
// 设置结束长度
let end = pageSize * number;
end = end > data.length ? data.length : end;
for (let i = start; i < end; i++) {
//所有分页数据 data
pagedata.push(data[i])
}
return pagedata;
},
//时间转换成想要的格式
turnTime(data, type) {
var date = new Date(data.replace(/-/g, "/"));
var YY = date.getFullYear()
var MM = '-' + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
var DD = '-' + (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
var ss = ':' + (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
if (type == 0) {
return hh + mm
} else if (type == 1) {
return YY + MM + DD
} else if (type == 2) {
return YY + MM + DD + " " + hh + mm;
} else {
return YY + MM + DD + " " + hh + mm + ss;
}
},
//当前时间跟指定时间相差多少分钟多少秒
getRemainderTime(startTime) {
var s1 = new Date(startTime.replace(/-/g, "/")),
s2 = new Date(),
runTime = parseInt((s2.getTime() - s1.getTime()) / 1000);
var year = Math.floor(runTime / 86400 / 365);
runTime = runTime % (86400 * 365);
var month = Math.floor(runTime / 86400 / 30);
runTime = runTime % (86400 * 30);
var day = Math.floor(runTime / 86400);
runTime = runTime % 86400;
var hour = Math.floor(runTime / 3600);
runTime = runTime % 3600;
var minute = Math.floor(runTime / 60);
runTime = runTime % 60;
var second = runTime;
//   return year+','+month+','+day+','+hour+','+minute+','+second;
return minute + ',' + second;
},
//获取当前时间
formatTime(type) {
var date = new Date(new Date().getTime());
var YY = date.getFullYear() + '-';
var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
var ss = ':' + (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
if (type == 1) {
return DD
} else if (type == 2) {
return YY + MM + DD + " " + hh + mm;
} else {
return YY + MM + DD + " " + hh + mm + ss;
}
},
//在指定日期上加多少分钟
MinutesTest(date, num) {
var sdate1 = new Date(date);
sdate1.setMinutes(sdate1.getMinutes() + num);
var YY = sdate1.getFullYear() + '-';
var MM = (sdate1.getMonth() + 1 < 10 ? '0' + (sdate1.getMonth() + 1) : sdate1.getMonth() + 1) + '-';
var DD = (sdate1.getDate() < 10 ? '0' + (sdate1.getDate()) : sdate1.getDate());
var hh = (sdate1.getHours() < 10 ? '0' + sdate1.getHours() : sdate1.getHours()) + ':';
var mm = (sdate1.getMinutes() < 10 ? '0' + sdate1.getMinutes() : sdate1.getMinutes());
var ss = ':' + (sdate1.getSeconds() < 10 ? '0' + sdate1.getSeconds() : sdate1.getSeconds());
// var now= sdate1.getHours()+":"+sdate1.getMinutes();
return YY + MM + DD + " " + hh + mm + ss;
},
//复制公用方法
copyFun(data) {
uni.setClipboardData({
data:data,
success: function(res) {
uni.showToast({
title:'复制成功',
icon:'none'
})
}
})
},
//获取指定日期加一天
getRearTime(time){
var day1 = new Date(time.replace(/-/g, "/"));
day1.setTime(day1.getTime()+24*60*60*1000);
var s1 = day1.getFullYear()+"-" + (day1.getMonth()+1) + "-" + day1.getDate();
let year = day1.getFullYear()
let month = (day1.getMonth()+1)<10?'0'+(day1.getMonth()+1):(day1.getMonth()+1)
let day = day1.getDate()<10?'0'+day1.getDate():day1.getDate()
let hh = (day1.getHours() < 10 ? '0' + day1.getHours() : day1.getHours()) + ':';
let mm = (day1.getMinutes() < 10 ? '0' + day1.getMinutes() : day1.getMinutes());
let ss = ':' + (day1.getSeconds() < 10 ? '0' + day1.getSeconds() : day1.getSeconds());
return year+'-'+month+'-'+day+ " " + hh + mm + ss;
},
}

View File

@ -11,6 +11,296 @@ import {
import permision from "./permission.js"
// #endif
export default {
forEach :function (arr, fn) {
if (!arr.length || !fn) return;
let i = -1;
let len = arr.length;
while (++i < len) {
let item = arr[i];
fn(item, i, arr);
}
},
/**
* @param {Array} arr1
* @param {Array} arr2
* @description 得到两个数组的交集, 两个数组的元素为数值或字符串
*/
getIntersection:function (arr1, arr2){
let len = Math.min(arr1.length, arr2.length);
let i = -1;
let res = [];
while (++i < len) {
const item = arr2[i];
if (arr1.indexOf(item) > -1) res.push(item);
}
return res;
},
/**
* @param {Array} arr1
* @param {Array} arr2
* @description 得到两个数组的并集, 两个数组的元素为数值或字符串
*/
getUnion :function (arr1, arr2) {
return Array.from(new Set([...arr1, ...arr2]));
},
/**
* @param {Array} target 目标数组
* @param {Array} arr 需要查询的数组
* @description 判断要查询的数组是否至少有一个元素包含在目标数组中
*/
hasOneOf :function (targetarr, arr) {
return targetarr.some((_) => arr.indexOf(_) > -1);
},
/**
* @param {String|Number} value 要验证的字符串或数值
* @param {*} validList 用来验证的列表
*/
oneOf:function (value, validList) {
for (let i = 0; i < validList.length; i++) {
if (value === validList[i]) {
return true;
}
}
return false;
},
/**
* @param {Number} timeStamp 判断时间戳格式是否是毫秒
* @returns {Boolean}
*/
isMillisecond :function (timeStamp){
const timeStr = String(timeStamp);
return timeStr.length > 10;
},
/**
* @param {Number} timeStamp 传入的时间戳
* @param {Number} currentTime 当前时间时间戳
* @returns {Boolean} 传入的时间戳是否早于当前时间戳
*/
isEarly :function (timeStamp, currentTime) {
return timeStamp < currentTime;
},
/**
* @param {Number} num 数值
* @returns {String} 处理后的字符串
* @description 如果传入的数值小于10即位数只有1位则在前面补充0
*/
getHandledValue :function (num){
return num < 10 ? '0' + num : num;
},
/**
* @param {Number} timeStamp 传入的时间戳
* @param {Number} startType 要返回的时间字符串的格式类型传入'year'则返回年开头的完整时间
*/
getDate :function (timeStamp, startType) {
const d = new Date(timeStamp * 1000);
const year = d.getFullYear();
const month = getHandledValue(d.getMonth() + 1);
const date = getHandledValue(d.getDate());
const hours = getHandledValue(d.getHours());
const minutes = getHandledValue(d.getMinutes());
const second = getHandledValue(d.getSeconds());
let resStr = '';
if (startType === 'year') resStr = year + '-' + month + '-' + date + ' ' + hours + ':' + minutes + ':' + second;
else resStr = month + '-' + date + ' ' + hours + ':' + minutes;
return resStr;
},
/**
* @param {String|Number} timeStamp 时间戳
* @returns {String} 相对时间字符串
*/
getRelativeTime :function (timeStamp){
// 判断当前传入的时间戳是秒格式还是毫秒
const IS_MILLISECOND = isMillisecond(timeStamp);
// 如果是毫秒格式则转为秒格式
if (IS_MILLISECOND) Math.floor((timeStamp /= 1000));
// 传入的时间戳可以是数值或字符串类型,这里统一转为数值类型
timeStamp = Number(timeStamp);
// 获取当前时间时间戳
const currentTime = Math.floor(Date.parse(new Date()) / 1000);
// 判断传入时间戳是否早于当前时间戳
const IS_EARLY = isEarly(timeStamp, currentTime);
// 获取两个时间戳差值
let diff = currentTime - timeStamp;
// 如果IS_EARLY为false则差值取反
if (!IS_EARLY) diff = -diff;
let resStr = '';
const dirStr = IS_EARLY ? '前' : '后';
// 少于等于59秒
if (diff <= 59) resStr = diff + '秒' + dirStr;
// 多于59秒少于等于59分钟59秒
else if (diff > 59 && diff <= 3599) resStr = Math.floor(diff / 60) + '分钟' + dirStr;
// 多于59分钟59秒少于等于23小时59分钟59秒
else if (diff > 3599 && diff <= 86399) resStr = Math.floor(diff / 3600) + '小时' + dirStr;
// 多于23小时59分钟59秒少于等于29天59分钟59秒
else if (diff > 86399 && diff <= 2623859) resStr = Math.floor(diff / 86400) + '天' + dirStr;
// 多于29天59分钟59秒少于364天23小时59分钟59秒且传入的时间戳早于当前
else if (diff > 2623859 && diff <= 31567859 && IS_EARLY) resStr = getDate(timeStamp);
else resStr = getDate(timeStamp, 'year');
return resStr;
},
/**
* @returns {String} 当前浏览器名称
*/
getExplorer :function (){
const ua = window.navigator.userAgent;
const isExplorer = (exp) => {
return ua.indexOf(exp) > -1;
};
if (isExplorer('MSIE')) return 'IE';
else if (isExplorer('Firefox')) return 'Firefox';
else if (isExplorer('Chrome')) return 'Chrome';
else if (isExplorer('Opera')) return 'Opera';
else if (isExplorer('Safari')) return 'Safari';
},
/**
* 判断一个对象是否存在key如果传入第二个参数key则是判断这个obj对象是否存在key这个属性
* 如果没有传入key这个参数则判断obj对象是否有键值对
*/
hasKey :function (obj, key) {
if (key) return key in obj;
else {
let keysArr = Object.keys(obj);
return keysArr.length;
}
},
/**
* @param {*} obj1 对象
* @param {*} obj2 对象
* @description 判断两个对象是否相等这两个对象的值只能是数字或字符串
*/
objEqual :function (obj1, obj2) {
const keysArr1 = Object.keys(obj1);
const keysArr2 = Object.keys(obj2);
if (keysArr1.length !== keysArr2.length) return false;
else if (keysArr1.length === 0 && keysArr2.length === 0) return true;
/* eslint-disable-next-line */ else return !keysArr1.some((key) => obj1[key] != obj2[key]);
},
/**
* 去除乘法计算出现多位小数
* @param arg1返回值arg2乘以的参数
*/
accMul :function (arg1, arg2){
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split('.')[1].length;
} catch (e) { }
try {
m += s2.split('.')[1].length;
} catch (e) { }
return (Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) / Math.pow(10, m);
},
hasOwn: function(obj, key) {
return hasOwnProperty.call(obj, key);
},
isVNode: function(node) {
return node !== null && typeof node === 'object' && hasOwn(node, 'componentOptions');
},
// 是否字符串
isString2: function(str) {
return (typeof str == 'string') && str.constructor == String;
},
isString: function(obj) {
return Object.prototype.toString.call(obj) === '[object String]';
},
isObject: function(obj) {
return Object.prototype.toString.call(obj) === '[object Object]';
},
isNumber: function(obj) {
return Object.prototype.toString.call(obj) === '[object Number]';
},
// 是否完整的
isDef: function(val) {
return val !== undefined && val !== null;
},
//
isKorean: function(text) {
const reg = /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi;
return reg.test(text);
},
isHtmlElement: function(node) {
return node && node.nodeType === Node.ELEMENT_NODE;
},
isUndefined : function(val) {
return val === void 0;
},
shortcuts: [
{
text: '今天',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()));
picker.$emit('pick', [start, end]);
},
},
{
text: '昨天',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(
start.setTime(new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1)),
);
end.setTime(end.setTime(new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1)));
picker.$emit('pick', [start, end]);
},
},
{
text: '最近7天',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
},
},
{
text: '最近30天',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
},
},
{
text: '本月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.setTime(new Date(new Date().getFullYear(), new Date().getMonth(), 1)));
picker.$emit('pick', [start, end]);
},
},
{
text: '本年',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.setTime(new Date(new Date().getFullYear(), 0, 1)));
picker.$emit('pick', [start, end]);
},
},
],
/**
* 字符串截取
* @obj 传入的数据