1
This commit is contained in:
@@ -10,26 +10,26 @@ let transformRequest = obj => {
|
|||||||
let query = ''
|
let query = ''
|
||||||
let name, value, fullSubName, subName, subValue, innerObj, i
|
let name, value, fullSubName, subName, subValue, innerObj, i
|
||||||
|
|
||||||
for(name in obj) {
|
for (name in obj) {
|
||||||
value = obj[name]
|
value = obj[name]
|
||||||
|
|
||||||
if(value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
for(i = 0; i < value.length; ++i) {
|
for (i = 0; i < value.length; ++i) {
|
||||||
subValue = value[i]
|
subValue = value[i]
|
||||||
fullSubName = name + '[' + i + ']'
|
fullSubName = name + '[' + i + ']'
|
||||||
innerObj = {}
|
innerObj = {}
|
||||||
innerObj[fullSubName] = subValue
|
innerObj[fullSubName] = subValue
|
||||||
query += transformRequest(innerObj) + '&'
|
query += transformRequest(innerObj) + '&'
|
||||||
}
|
}
|
||||||
} else if(value instanceof Object) {
|
} else if (value instanceof Object) {
|
||||||
for(subName in value) {
|
for (subName in value) {
|
||||||
subValue = value[subName]
|
subValue = value[subName]
|
||||||
fullSubName = name + '[' + subName + ']'
|
fullSubName = name + '[' + subName + ']'
|
||||||
innerObj = {}
|
innerObj = {}
|
||||||
innerObj[fullSubName] = subValue
|
innerObj[fullSubName] = subValue
|
||||||
query += transformRequest(innerObj) + '&'
|
query += transformRequest(innerObj) + '&'
|
||||||
}
|
}
|
||||||
} else if(value !== undefined && value !== null) {
|
} else if (value !== undefined && value !== null) {
|
||||||
query += encodeURIComponent(name) + '=' +
|
query += encodeURIComponent(name) + '=' +
|
||||||
encodeURIComponent(value) + '&'
|
encodeURIComponent(value) + '&'
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ let timestamp = function() {
|
|||||||
|
|
||||||
let isNavigating = false
|
let isNavigating = false
|
||||||
let isNavigate = () => {
|
let isNavigate = () => {
|
||||||
if(isNavigating) {
|
if (isNavigating) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
isNavigating = true
|
isNavigating = true
|
||||||
@@ -62,11 +62,11 @@ let guid = (function() {
|
|||||||
let guid = new Date().getTime().toString(32),
|
let guid = new Date().getTime().toString(32),
|
||||||
i
|
i
|
||||||
|
|
||||||
for(i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
guid += Math.floor(Math.random() * 65535).toString(32)
|
guid += Math.floor(Math.random() * 65535).toString(32)
|
||||||
}
|
}
|
||||||
|
|
||||||
return(prefix || '') + guid + (counter++).toString(32)
|
return (prefix || '') + guid + (counter++).toString(32)
|
||||||
}
|
}
|
||||||
}())
|
}())
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ let sortTransform = (obj) => {
|
|||||||
objKeys = objKeys.sort()
|
objKeys = objKeys.sort()
|
||||||
|
|
||||||
var ret = {}
|
var ret = {}
|
||||||
for(var i = 0; i < objKeys.length; i++) {
|
for (var i = 0; i < objKeys.length; i++) {
|
||||||
let objVal = obj[objKeys[i]]
|
let objVal = obj[objKeys[i]]
|
||||||
ret[objKeys[i]] = objVal
|
ret[objKeys[i]] = objVal
|
||||||
}
|
}
|
||||||
@@ -95,8 +95,8 @@ function isEmptyObject(v) {
|
|||||||
return Object.keys(v).length == 0
|
return Object.keys(v).length == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function sleep (time) {
|
function sleep(time) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, time))
|
return new Promise((resolve) => setTimeout(resolve, time))
|
||||||
}
|
}
|
||||||
|
|
||||||
const throttle = function(func, wait = 200, options) {
|
const throttle = function(func, wait = 200, options) {
|
||||||
@@ -110,7 +110,7 @@ const throttle = function(func, wait = 200, options) {
|
|||||||
var context, args, result
|
var context, args, result
|
||||||
var timeout = null
|
var timeout = null
|
||||||
var previous = 0
|
var previous = 0
|
||||||
if(!options) options = {
|
if (!options) options = {
|
||||||
leading: true,
|
leading: true,
|
||||||
trailing: false
|
trailing: false
|
||||||
}
|
}
|
||||||
@@ -118,26 +118,26 @@ const throttle = function(func, wait = 200, options) {
|
|||||||
previous = options.leading === false ? 0 : new Date().getTime()
|
previous = options.leading === false ? 0 : new Date().getTime()
|
||||||
timeout = null
|
timeout = null
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args)
|
||||||
if(!timeout) context = args = null
|
if (!timeout) context = args = null
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
var now = new Date().getTime()
|
var now = new Date().getTime()
|
||||||
if(!previous && options.leading === false) previous = now
|
if (!previous && options.leading === false) previous = now
|
||||||
// 计算剩余时间
|
// 计算剩余时间
|
||||||
var remaining = wait - (now - previous)
|
var remaining = wait - (now - previous)
|
||||||
context = this
|
context = this
|
||||||
args = arguments
|
args = arguments
|
||||||
// 当到达wait指定的时间间隔,则调用func函数
|
// 当到达wait指定的时间间隔,则调用func函数
|
||||||
if(remaining <= 0 || remaining > wait) {
|
if (remaining <= 0 || remaining > wait) {
|
||||||
// 由于setTimeout存在最小时间精度问题,因此会存在到达wait的时间间隔,但之前设置的setTimeout操作还没被执行,因此为保险起见,这里先清理setTimeout操作
|
// 由于setTimeout存在最小时间精度问题,因此会存在到达wait的时间间隔,但之前设置的setTimeout操作还没被执行,因此为保险起见,这里先清理setTimeout操作
|
||||||
if(timeout) {
|
if (timeout) {
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout)
|
||||||
timeout = null
|
timeout = null
|
||||||
}
|
}
|
||||||
previous = now
|
previous = now
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args)
|
||||||
if(!timeout) context = args = null
|
if (!timeout) context = args = null
|
||||||
} else if(!timeout && options.trailing !== false) {
|
} else if (!timeout && options.trailing !== false) {
|
||||||
// options.trailing=true时,延时执行func函数
|
// options.trailing=true时,延时执行func函数
|
||||||
timeout = setTimeout(later, remaining)
|
timeout = setTimeout(later, remaining)
|
||||||
}
|
}
|
||||||
@@ -153,13 +153,13 @@ const debounce = function(func, wait, immediate) {
|
|||||||
// 当wait指定的时间间隔期间多次调用_.debounce返回的函数,则会不断更新timestamp的值,导致last < wait && last >= 0一直为true,从而不断启动新的计时器延时执行func
|
// 当wait指定的时间间隔期间多次调用_.debounce返回的函数,则会不断更新timestamp的值,导致last < wait && last >= 0一直为true,从而不断启动新的计时器延时执行func
|
||||||
var last = new Date().getTime() - timestamp
|
var last = new Date().getTime() - timestamp
|
||||||
|
|
||||||
if(last < wait && last >= 0) {
|
if (last < wait && last >= 0) {
|
||||||
timeout = setTimeout(later, wait - last)
|
timeout = setTimeout(later, wait - last)
|
||||||
} else {
|
} else {
|
||||||
timeout = null
|
timeout = null
|
||||||
if(!immediate) {
|
if (!immediate) {
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args)
|
||||||
if(!timeout) context = args = null
|
if (!timeout) context = args = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,8 +171,8 @@ const debounce = function(func, wait, immediate) {
|
|||||||
// 第一次调用该方法时,且immediate为true,则调用func函数
|
// 第一次调用该方法时,且immediate为true,则调用func函数
|
||||||
var callNow = immediate && !timeout
|
var callNow = immediate && !timeout
|
||||||
// 在wait指定的时间间隔内首次调用该方法,则启动计时器定时调用func函数
|
// 在wait指定的时间间隔内首次调用该方法,则启动计时器定时调用func函数
|
||||||
if(!timeout) timeout = setTimeout(later, wait)
|
if (!timeout) timeout = setTimeout(later, wait)
|
||||||
if(callNow) {
|
if (callNow) {
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args)
|
||||||
context = args = null
|
context = args = null
|
||||||
}
|
}
|
||||||
@@ -181,12 +181,14 @@ const debounce = function(func, wait, immediate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.prototype.finally = function (callback) {
|
Promise.prototype.finally = function(callback) {
|
||||||
let P = this.constructor
|
let P = this.constructor
|
||||||
return this.then(
|
return this.then(
|
||||||
value => P.resolve(callback()).then(() => value),
|
value => P.resolve(callback()).then(() => value),
|
||||||
reason => P.resolve(callback()).then(() => { throw reason })
|
reason => P.resolve(callback()).then(() => {
|
||||||
)
|
throw reason
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
const info_distance = function(e) { //获取元素位置
|
const info_distance = function(e) { //获取元素位置
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -204,6 +206,37 @@ const getCurrentRoute = function() {
|
|||||||
return '/' + getCurrentPage().route
|
return '/' + getCurrentPage().route
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pluschooseImage = function() {
|
||||||
|
// #ifdef APP
|
||||||
|
if (plus.os.name == 'Android' && plus.navigator.checkPermission('android.permission.CAMERA') ===
|
||||||
|
'undetermined') {
|
||||||
|
//未授权
|
||||||
|
uni.showModal({
|
||||||
|
title: '权限说明',
|
||||||
|
content: '便于您使用该功能上传您的照片/图片等,请您确认授权相机与相册,否则无法使用该功能',
|
||||||
|
confirmText: "去设置",
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
uni.openAppAuthorizeSetting({
|
||||||
|
success(res) {
|
||||||
|
console.log(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (res.cancel) {
|
||||||
|
console.log('用户点击取消');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
return true
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
|
||||||
uni.utils = {
|
uni.utils = {
|
||||||
md5,
|
md5,
|
||||||
transformRequest,
|
transformRequest,
|
||||||
@@ -219,5 +252,6 @@ uni.utils = {
|
|||||||
throttle,
|
throttle,
|
||||||
debounce,
|
debounce,
|
||||||
getCurrentPage,
|
getCurrentPage,
|
||||||
getCurrentRoute
|
getCurrentRoute,
|
||||||
}
|
pluschooseImage
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="towcontent flex-between">
|
<view class="towcontent flex-between">
|
||||||
<view class="towcontent_item flex-colum" v-for="(item,index) in district" :key="index">
|
<view class="towcontent_item flex-colum" v-for="(item,index) in district" :key="index"
|
||||||
|
@click="clickdistrict(item,index)">
|
||||||
<image :src="item.coverImg" mode="aspectFill"></image>
|
<image :src="item.coverImg" mode="aspectFill"></image>
|
||||||
<text>{{item.name}}</text>
|
<text>{{item.name}}</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -28,6 +29,53 @@
|
|||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
clickdistrict(item) {
|
||||||
|
uni.pro.navigateTo('index/coupons/index');
|
||||||
|
switch (item.jumpType) {
|
||||||
|
case 'absolute':
|
||||||
|
uni.pro.navigateTo('webview/webview', {
|
||||||
|
url: item.absUrl
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'relative':
|
||||||
|
uni.pro.navigateTo(item.absUrl);
|
||||||
|
break;
|
||||||
|
case 'scan':
|
||||||
|
if (!uni.utils.pluschooseImage()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// #ifdef H5
|
||||||
|
if (this.wxSdk) {
|
||||||
|
wx.scanQRCode({
|
||||||
|
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
||||||
|
scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
|
||||||
|
success: res => {
|
||||||
|
// 当needResult 为 1 时,扫码返回的结果
|
||||||
|
console.log(res.resultStr,res)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.showModal({
|
||||||
|
title: '注意',
|
||||||
|
content: '微信sdk初始化失败,请重新加载',
|
||||||
|
success: res => {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
// #ifdef APP || MP-WEIXIN
|
||||||
|
uni.scanCode({
|
||||||
|
success: res => {
|
||||||
|
console.log(res.result,res)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
46
pages/index/coupons/index.vue
Normal file
46
pages/index/coupons/index.vue
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<view class="containertop">
|
||||||
|
<view class="containertopbox">
|
||||||
|
<view class="containertopboxone flex-start">
|
||||||
|
<view>可使用红包</view>
|
||||||
|
<view>200张</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.container {
|
||||||
|
.containertop {
|
||||||
|
padding: 48rpx 32rpx;
|
||||||
|
|
||||||
|
.containertopbox {
|
||||||
|
.containertopboxone{
|
||||||
|
view{
|
||||||
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
text{
|
||||||
|
margin-left: 12rpx;
|
||||||
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #666666;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user