Skip to content

Commit 5c3810d

Browse files
committed
update to ver. 2.0.1
1 parent 29f4b65 commit 5c3810d

File tree

10 files changed

+208
-158
lines changed

10 files changed

+208
-158
lines changed

App.vue

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
goLogin: false,
99
subDomain: 'tz', // jdjf0115
1010
merchantId: 951, // 42151
11-
version: '2.0.0',
11+
version: '2.0.1',
1212
sysconfigkeys: 'mallName,shopMod,share_profile,recharge_amount_min,open_growth,shopping_cart_vop_open,needIdCheck',
1313
wxpayOpenAppId: 'wx9b04553fd8c7b9c3', // 微信开放平台的移动端应用appID
1414
openAlipayProvider: false, // 是否开通支付宝支付
1515
addressLevel: 3, // 省市区到3级还是4级,可选 3 或者 4
16+
curLong: undefined, // 当前用户经纬度
17+
curLat: undefined, // 当前用户经纬度
1618
},
1719
onLaunch: function() {
1820
// https://www.yuque.com/apifm/nu0f75/cdqz1n
@@ -185,7 +187,27 @@
185187
uni.$emit('loginOK', {})
186188
}, 500)
187189
}
188-
}
190+
},
191+
async getLocation() {
192+
// 统一获取经纬度
193+
if (this.globalData.curLong && this.globalData.curLat) {
194+
return {
195+
long: this.globalData.curLong,
196+
lat: this.globalData.curLat
197+
}
198+
}
199+
const res = await this.$wxapi.getLocation()
200+
if (res) {
201+
this.globalData.curLong = res.long
202+
this.globalData.curLat = res.lat
203+
return res
204+
} else {
205+
return {
206+
long: 0,
207+
lat: 0
208+
}
209+
}
210+
},
189211
}
190212
}
191213
</script>

pages/notagree.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<view class="profile">
55
很遗憾,若您不同意《用户协议》和《隐私协议》,将无法继续使用我们的服务。
66
</view>
7-
<image class="img" width="100%" mode="widthFix" src="https://7.s2m.cc/2021/11/30/efd832a3-5184-4c22-af64-728999a90add.png"></image>
7+
<image class="img" width="100%" mode="widthFix" src="https://dcdn.it120.cc/2023/01/03/b68c3363-a598-4e8e-b51a-014dd824c687.png"></image>
88
</view>
99
</template>
1010

uni_modules/uview-ui/LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 www.uviewui.com
3+
Copyright (c) 2023 www.uviewui.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

uni_modules/uview-ui/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.0.36(2023-03-27)
2+
# uView2.0重磅发布,利剑出鞘,一统江湖
3+
4+
1. 重构`deepClone` & `deepMerge`方法
5+
2. 其他优化
16
## 2.0.34(2022-09-24)
27
# uView2.0重磅发布,利剑出鞘,一统江湖
38

uni_modules/uview-ui/components/u-modal/u-modal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
* @event {Function} confirm 点击确认按钮时触发
115115
* @event {Function} cancel 点击取消按钮时触发
116116
* @event {Function} close 点击遮罩关闭出发,closeOnClickOverlay为true有效
117-
* @example <u-loadmore :status="status" icon-type="iconType" load-text="loadText" />
117+
* @example <u-modal :show="true" title="title" content="content"></u-modal>
118118
*/
119119
export default {
120120
name: 'u-modal',

uni_modules/uview-ui/components/u-text/props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default {
8383
},
8484
// 文字装饰,下划线,中划线等,可选值 none|underline|line-through
8585
decoration: {
86-
tepe: String,
86+
type: String,
8787
default: uni.$u.props.text.decoration
8888
},
8989
// 外边距,对象、字符串,数值形式均可

uni_modules/uview-ui/libs/config/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// 此版本发布于2022-00-24
2-
const version = '2.0.34'
1+
// 此版本发布于2023-03-27
2+
const version = '2.0.36'
33

44
// 开发环境才提示,生产环境不会提示
55
if (process.env.NODE_ENV === 'development') {

uni_modules/uview-ui/libs/function/index.js

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import test from './test.js'
22
import { round } from './digit.js'
33
/**
44
* @description 如果value小于min,取min;如果value大于max,取max
5-
* @param {number} min
6-
* @param {number} max
5+
* @param {number} min
6+
* @param {number} max
77
* @param {number} value
88
*/
99
function range(min = 0, max = 0, value = 0) {
@@ -13,7 +13,7 @@ function range(min = 0, max = 0, value = 0) {
1313
/**
1414
* @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.upx2px进行转换
1515
* @param {number|string} value 用户传递值的px值
16-
* @param {boolean} unit
16+
* @param {boolean} unit
1717
* @returns {number|string}
1818
*/
1919
function getPx(value, unit = false) {
@@ -41,15 +41,15 @@ function sleep(value = 30) {
4141
}
4242
/**
4343
* @description 运行期判断平台
44-
* @returns {string} 返回所在平台(小写)
44+
* @returns {string} 返回所在平台(小写)
4545
* @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台
4646
*/
4747
function os() {
4848
return uni.getSystemInfoSync().platform.toLowerCase()
4949
}
5050
/**
5151
* @description 获取系统信息同步接口
52-
* @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync
52+
* @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync
5353
*/
5454
function sys() {
5555
return uni.getSystemInfoSync()
@@ -179,22 +179,34 @@ function addUnit(value = 'auto', unit = uni?.$u?.config?.unit ?? 'px') {
179179
/**
180180
* @description 深度克隆
181181
* @param {object} obj 需要深度克隆的对象
182+
* @param cache 缓存
182183
* @returns {*} 克隆后的对象或者原值(不是对象)
183184
*/
184-
function deepClone(obj) {
185-
// 对常见的“非”值,直接返回原来值
186-
if ([null, undefined, NaN, false].includes(obj)) return obj
187-
if (typeof obj !== 'object' && typeof obj !== 'function') {
188-
// 原始类型直接返回
189-
return obj
190-
}
191-
const o = test.array(obj) ? [] : {}
192-
for (const i in obj) {
193-
if (obj.hasOwnProperty(i)) {
194-
o[i] = typeof obj[i] === 'object' ? deepClone(obj[i]) : obj[i]
185+
function deepClone(obj, cache = new WeakMap()) {
186+
if (obj === null || typeof obj !== 'object') return obj;
187+
if (cache.has(obj)) return cache.get(obj);
188+
let clone;
189+
if (obj instanceof Date) {
190+
clone = new Date(obj.getTime());
191+
} else if (obj instanceof RegExp) {
192+
clone = new RegExp(obj);
193+
} else if (obj instanceof Map) {
194+
clone = new Map(Array.from(obj, ([key, value]) => [key, deepClone(value, cache)]));
195+
} else if (obj instanceof Set) {
196+
clone = new Set(Array.from(obj, value => deepClone(value, cache)));
197+
} else if (Array.isArray(obj)) {
198+
clone = obj.map(value => deepClone(value, cache));
199+
} else if (Object.prototype.toString.call(obj) === '[object Object]') {
200+
clone = Object.create(Object.getPrototypeOf(obj));
201+
cache.set(obj, clone);
202+
for (const [key, value] of Object.entries(obj)) {
203+
clone[key] = deepClone(value, cache);
195204
}
205+
} else {
206+
clone = Object.assign({}, obj);
196207
}
197-
return o
208+
cache.set(obj, clone);
209+
return clone;
198210
}
199211

200212
/**
@@ -205,24 +217,27 @@ function deepClone(obj) {
205217
*/
206218
function deepMerge(target = {}, source = {}) {
207219
target = deepClone(target)
208-
if (typeof target !== 'object' || typeof source !== 'object') return false
220+
if (typeof target !== 'object' || target === null || typeof source !== 'object' || source === null) return target;
221+
const merged = Array.isArray(target) ? target.slice() : Object.assign({}, target);
209222
for (const prop in source) {
210-
if (!source.hasOwnProperty(prop)) continue
211-
if (prop in target) {
212-
if (typeof target[prop] !== 'object') {
213-
target[prop] = source[prop]
214-
} else if (typeof source[prop] !== 'object') {
215-
target[prop] = source[prop]
216-
} else if (target[prop].concat && source[prop].concat) {
217-
target[prop] = target[prop].concat(source[prop])
218-
} else {
219-
target[prop] = deepMerge(target[prop], source[prop])
220-
}
223+
if (!source.hasOwnProperty(prop)) continue;
224+
const sourceValue = source[prop];
225+
const targetValue = merged[prop];
226+
if (sourceValue instanceof Date) {
227+
merged[prop] = new Date(sourceValue);
228+
} else if (sourceValue instanceof RegExp) {
229+
merged[prop] = new RegExp(sourceValue);
230+
} else if (sourceValue instanceof Map) {
231+
merged[prop] = new Map(sourceValue);
232+
} else if (sourceValue instanceof Set) {
233+
merged[prop] = new Set(sourceValue);
234+
} else if (typeof sourceValue === 'object' && sourceValue !== null) {
235+
merged[prop] = deepMerge(targetValue, sourceValue);
221236
} else {
222-
target[prop] = source[prop]
237+
merged[prop] = sourceValue;
223238
}
224239
}
225-
return target
240+
return merged;
226241
}
227242

228243
/**
@@ -327,7 +342,7 @@ if (!String.prototype.padStart) {
327342
/**
328343
* @description 时间戳转为多久之前
329344
* @param {String|Number} timestamp 时间戳
330-
* @param {String|Boolean} format
345+
* @param {String|Boolean} format
331346
* 格式化规则如果为时间格式字符串,超出一定时间范围,返回固定的时间格式;
332347
* 如果为布尔值false,无论什么时间,都返回多久以前的格式
333348
* @returns {string} 转化后的内容
@@ -517,7 +532,7 @@ function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparato
517532
while (re.test(s[0])) {
518533
s[0] = s[0].replace(re, `$1${sep}$2`)
519534
}
520-
535+
521536
if ((s[1] || '').length < prec) {
522537
s[1] = s[1] || ''
523538
s[1] += new Array(prec - s[1].length + 1).join('0')
@@ -531,7 +546,7 @@ function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparato
531546
* 比如以30位阈值,那么300大于30,可以理解为用户想要的是300ms,而不是想花300s去执行一个动画
532547
* @param {String|number} value 比如: "1s"|"100ms"|1|100
533548
* @param {boolean} unit 提示: 如果是false 默认返回number
534-
* @return {string|number}
549+
* @return {string|number}
535550
*/
536551
function getDuration(value, unit = true) {
537552
const valueNum = parseInt(value)
@@ -650,6 +665,16 @@ function pages() {
650665
return pages
651666
}
652667

668+
/**
669+
* 获取页面历史栈指定层实例
670+
* @param back {number} [0] - 0或者负数,表示获取历史栈的哪一层,0表示获取当前页面实例,-1 表示获取上一个页面实例。默认0。
671+
*/
672+
function getHistoryPage(back = 0) {
673+
const pages = getCurrentPages()
674+
const len = pages.length
675+
return pages[len - 1 + back]
676+
}
677+
653678
/**
654679
* @description 修改uView内置属性值
655680
* @param {object} props 修改内置props属性
@@ -701,5 +726,6 @@ export default {
701726
setProperty,
702727
page,
703728
pages,
729+
getHistoryPage,
704730
setConfig
705731
}

0 commit comments

Comments
 (0)