提交
This commit is contained in:
140
common/commonJS.js
Normal file
140
common/commonJS.js
Normal file
@@ -0,0 +1,140 @@
|
||||
|
||||
import uniCopy from '@/js_sdk/xb-copy/uni-copy.js'
|
||||
import $http from '@/config/requestConfig'
|
||||
import { mapState, mapMutations } from "vuex";
|
||||
|
||||
export default {
|
||||
...mapMutations(["setUserInfo"]),
|
||||
|
||||
showToast(title, icon) {
|
||||
return uni.showToast({
|
||||
title: title,
|
||||
icon: icon ? icon : 'none'
|
||||
})
|
||||
},
|
||||
//拨打电话
|
||||
handleMakingPhoneCalls(value, title) {
|
||||
uni.showModal({
|
||||
title: title ? title : '联系我们',
|
||||
content: value,
|
||||
confirmText: '确认',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: value, //电话号码
|
||||
success: function (e) {
|
||||
console.log(e);
|
||||
},
|
||||
fail: function (e) {
|
||||
console.log(e);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//复制内容
|
||||
handleCopy(value, title) {
|
||||
uniCopy({
|
||||
content: value,
|
||||
success: (res) => {
|
||||
uni.showToast({
|
||||
title: title + '复制成功',
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
error: (e) => {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//用户协议
|
||||
async getAgreement(id) {
|
||||
console.log('id at line 56:', id)
|
||||
var data = {
|
||||
id: id
|
||||
}
|
||||
var result = {
|
||||
title:'',
|
||||
content:''
|
||||
}
|
||||
await $http
|
||||
.request({
|
||||
url: "sys/agreement/getAgreement",
|
||||
method: "POST",
|
||||
data: data,
|
||||
header: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}).then((res) => {
|
||||
console.log('res at line 111:', res)
|
||||
if (res.code == 0) {
|
||||
result = res.agreement
|
||||
}
|
||||
|
||||
})
|
||||
return result
|
||||
},
|
||||
async getCheckCourseStatus(data) {
|
||||
var result
|
||||
await $http
|
||||
.post('app/phone.do?getCheckCourseStatus', {
|
||||
customerType
|
||||
:
|
||||
"D",
|
||||
token
|
||||
: uni.getStorageSync("token")
|
||||
,
|
||||
customerOid
|
||||
: uni.getStorageSync("customerOid"),
|
||||
oid: data.oid
|
||||
})
|
||||
.then(async res => {
|
||||
result = res.obj
|
||||
})
|
||||
return result
|
||||
},
|
||||
// 退出登录
|
||||
signOut() {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "确定要退出当前账户吗?",
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
setUserInfo({ token: null });
|
||||
uni.reLaunch({
|
||||
url: "/pages/user/login",
|
||||
});
|
||||
} else if (res.cancel) {
|
||||
// 取消操作
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
// 注销账户
|
||||
logout() {
|
||||
let that = this;
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "确定要注销当前账户吗?",
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
showCancel: false,
|
||||
content: `注销申请已提交成功,请联系客服进行后续操作:022-24142321`,
|
||||
success: function (res1) {
|
||||
if (res1.confirm) {
|
||||
that.signOut();
|
||||
}
|
||||
},
|
||||
});
|
||||
} else if (res.cancel) {
|
||||
// 取消操作
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
29
common/debounce.js
Normal file
29
common/debounce.js
Normal file
@@ -0,0 +1,29 @@
|
||||
let timeout = null
|
||||
|
||||
/**
|
||||
* 防抖原理:一定时间内,只有最后一次操作,再过wait毫秒后才执行函数
|
||||
*
|
||||
* @param {Function} func 要执行的回调函数
|
||||
* @param {Number} wait 延时的时间
|
||||
* @param {Boolean} immediate 是否立即执行
|
||||
* @return null
|
||||
*/
|
||||
function debounce(func, wait = 500, immediate = false) {
|
||||
// 清除定时器
|
||||
if (timeout !== null) clearTimeout(timeout)
|
||||
// 立即执行,此类情况一般用不到
|
||||
if (immediate) {
|
||||
const callNow = !timeout
|
||||
timeout = setTimeout(() => {
|
||||
timeout = null
|
||||
}, wait)
|
||||
if (callNow) typeof func === 'function' && func()
|
||||
} else {
|
||||
// 设置定时器,当最后一次操作后,timeout不会再被清除,所以在延时wait毫秒后执行func回调方法
|
||||
timeout = setTimeout(() => {
|
||||
typeof func === 'function' && func()
|
||||
}, wait)
|
||||
}
|
||||
}
|
||||
|
||||
export default debounce
|
||||
136
common/uni-nvue.css
Normal file
136
common/uni-nvue.css
Normal file
@@ -0,0 +1,136 @@
|
||||
/* #ifndef APP-PLUS-NVUE */
|
||||
page {
|
||||
min-height: 100%;
|
||||
height: auto;
|
||||
}
|
||||
/* #endif */
|
||||
|
||||
/* 解决头条小程序字体图标不显示问题,因为头条运行时自动插入了span标签,且有全局字体 */
|
||||
/* #ifdef MP-TOUTIAO */
|
||||
/* text :not(view) {
|
||||
font-family: uniicons;
|
||||
} */
|
||||
/* #endif */
|
||||
|
||||
.uni-icon {
|
||||
font-family: uniicons;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.uni-container {
|
||||
padding: 15px;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.uni-header-logo {
|
||||
/* #ifdef H5 */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
padding: 15px 15px;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.uni-header-image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
.uni-hello-text {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.hello-text {
|
||||
color: #7A7E83;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.hello-link {
|
||||
color: #7A7E83;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.uni-panel {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.uni-panel-h {
|
||||
/* #ifdef H5 */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
background-color: #ffffff;
|
||||
flex-direction: row !important;
|
||||
/* justify-content: space-between !important; */
|
||||
align-items: center !important;
|
||||
padding: 12px;
|
||||
/* #ifdef H5 */
|
||||
cursor: pointer;
|
||||
/* #endif */
|
||||
}
|
||||
/*
|
||||
.uni-panel-h:active {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
*/
|
||||
.uni-panel-h-on {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.uni-panel-text {
|
||||
flex: 1;
|
||||
color: #000000;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.uni-panel-icon {
|
||||
margin-left: 15px;
|
||||
color: #999999;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
transform: rotate(0deg);
|
||||
transition-duration: 0s;
|
||||
transition-property: transform;
|
||||
}
|
||||
|
||||
.uni-panel-icon-on {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.uni-navigate-item {
|
||||
/* #ifdef H5 */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
background-color: #FFFFFF;
|
||||
border-top-style: solid;
|
||||
border-top-color: #f5f5f5;
|
||||
border-top-width: 1px;
|
||||
padding: 12px;
|
||||
/* #ifdef H5 */
|
||||
cursor: pointer;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.uni-navigate-item:active {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.uni-navigate-text {
|
||||
flex: 1;
|
||||
color: #000000;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.uni-navigate-icon {
|
||||
margin-left: 15px;
|
||||
color: #999999;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
1434
common/uni.css
Normal file
1434
common/uni.css
Normal file
File diff suppressed because it is too large
Load Diff
74
common/util.js
Normal file
74
common/util.js
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
function formatTime(time) {
|
||||
if (typeof time !== 'number' || time < 0) {
|
||||
return time
|
||||
}
|
||||
|
||||
var hour = parseInt(time / 3600)
|
||||
time = time % 3600
|
||||
var minute = parseInt(time / 60)
|
||||
time = time % 60
|
||||
var second = time
|
||||
|
||||
return ([hour, minute, second]).map(function (n) {
|
||||
n = n.toString()
|
||||
return n[1] ? n : '0' + n
|
||||
}).join(':')
|
||||
}
|
||||
|
||||
function formatLocation(longitude, latitude) {
|
||||
if (typeof longitude === 'string' && typeof latitude === 'string') {
|
||||
longitude = parseFloat(longitude)
|
||||
latitude = parseFloat(latitude)
|
||||
}
|
||||
|
||||
longitude = longitude.toFixed(2)
|
||||
latitude = latitude.toFixed(2)
|
||||
|
||||
return {
|
||||
longitude: longitude.toString().split('.'),
|
||||
latitude: latitude.toString().split('.')
|
||||
}
|
||||
}
|
||||
var dateUtils = {
|
||||
UNITS: {
|
||||
'年': 31557600000,
|
||||
'月': 2629800000,
|
||||
'天': 86400000,
|
||||
'小时': 3600000,
|
||||
'分钟': 60000,
|
||||
'秒': 1000
|
||||
},
|
||||
humanize: function (milliseconds) {
|
||||
var humanize = '';
|
||||
for (var key in this.UNITS) {
|
||||
if (milliseconds >= this.UNITS[key]) {
|
||||
humanize = Math.floor(milliseconds / this.UNITS[key]) + key + '前';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return humanize || '刚刚';
|
||||
},
|
||||
format: function (dateStr) {
|
||||
var date = this.parse(dateStr)
|
||||
var diff = Date.now() - date.getTime();
|
||||
if (diff < this.UNITS['天']) {
|
||||
return this.humanize(diff);
|
||||
}
|
||||
var _format = function (number) {
|
||||
return (number < 10 ? ('0' + number) : number);
|
||||
};
|
||||
return date.getFullYear() + '/' + _format(date.getMonth() + 1) + '/' + _format(date.getDate()) + '-' +
|
||||
_format(date.getHours()) + ':' + _format(date.getMinutes());
|
||||
},
|
||||
parse: function (str) { //将"yyyy-mm-dd HH:MM:ss"格式的字符串,转化为一个Date对象
|
||||
var a = str.split(/[^0-9]/);
|
||||
return new Date(a[0], a[1] - 1, a[2], a[3], a[4], a[5]);
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
formatTime,
|
||||
formatLocation,
|
||||
dateUtils
|
||||
}
|
||||
Reference in New Issue
Block a user