From fd924cce36d663c5d5ad1fc3c0f035bb617a3368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B1=AA?= <781521347@qq.com> Date: Wed, 3 Nov 2021 14:40:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E8=B4=B9=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 +- config/index.js | 4 +- dist/mixins/basic.js | 21 +++++ dist/mixins/button.js | 63 ++++++++++++++ dist/mixins/link.js | 32 +++++++ dist/mixins/page-scroll.js | 41 +++++++++ dist/mixins/touch.js | 47 ++++++++++ dist/mixins/transition.js | 156 ++++++++++++++++++++++++++++++++++ dist/wxs/add-unit.wxs | 12 +++ dist/wxs/array.wxs | 5 ++ dist/wxs/bem.wxs | 52 ++++++++++++ dist/wxs/memoize.wxs | 52 ++++++++++++ dist/wxs/object.wxs | 10 +++ dist/wxs/style.wxs | 45 ++++++++++ dist/wxs/utils.wxs | 128 ++++++++++++++++++++++++++++ pages.json | 3 +- pages/demandHall/index.vue | 2 +- pages/life/addGoods/index.vue | 36 ++------ pages/life/tempList/index.vue | 4 + pages/shop/GoodsCon/index.vue | 2 +- 20 files changed, 683 insertions(+), 38 deletions(-) create mode 100644 dist/mixins/basic.js create mode 100644 dist/mixins/button.js create mode 100644 dist/mixins/link.js create mode 100644 dist/mixins/page-scroll.js create mode 100644 dist/mixins/touch.js create mode 100644 dist/mixins/transition.js create mode 100644 dist/wxs/add-unit.wxs create mode 100644 dist/wxs/array.wxs create mode 100644 dist/wxs/bem.wxs create mode 100644 dist/wxs/memoize.wxs create mode 100644 dist/wxs/object.wxs create mode 100644 dist/wxs/style.wxs create mode 100644 dist/wxs/utils.wxs diff --git a/.gitignore b/.gitignore index f1bfc81..9f4f065 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,7 @@ node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* -unpackage/ -dist/ +unpackage # Editor directories and files .idea @@ -16,6 +15,3 @@ dist/ assets/css/style.css assets/css/style.css.map .hbuilderx - -unpackage/dist -unpackage/resources diff --git a/config/index.js b/config/index.js index dbb5bee..8e1318a 100644 --- a/config/index.js +++ b/config/index.js @@ -1,8 +1,8 @@ // export const VUE_APP_API_URL = 'http://natapp.xinxintuan.co/api'; // export const VUE_APP_API_URL = 'https://wxapi.yixiang.co/api' -// export const VUE_APP_API_URL = 'http://192.168.0.112:8092/api' +export const VUE_APP_API_URL = 'http://192.168.0.112:8092/api' // export const VUE_APP_API_URL = 'http://192.168.0.111:8092/api' -export const VUE_APP_API_URL = 'https://cloud.api.cyjyyjy.com/api' +// export const VUE_APP_API_URL = 'https://cloud.api.cyjyyjy.com/api' // export const VUE_APP_API_URL = 'http://natapp.xinxintuan.co/api'; // export const VUE_APP_API_URL = 'https://thapi.xinxintuan.co/api' // export const VUE_APP_API_URL = 'https://h5api.xinxintuan.co/api'; diff --git a/dist/mixins/basic.js b/dist/mixins/basic.js new file mode 100644 index 0000000..0c93012 --- /dev/null +++ b/dist/mixins/basic.js @@ -0,0 +1,21 @@ + +module.exports = { + data() { + return {}; + }, + + props: {}, + methods: { + $emit(name, detail, options) { + this.$emit(name, { + detail: detail + }, options); + }, + + set(data) { + this.setData(data); + return new Promise(resolve => uni.nextTick(resolve)); + } + + } +}; \ No newline at end of file diff --git a/dist/mixins/button.js b/dist/mixins/button.js new file mode 100644 index 0000000..a0bcdd4 --- /dev/null +++ b/dist/mixins/button.js @@ -0,0 +1,63 @@ +import { canIUseGetUserProfile } from '../common/version'; + +module.exports = { + data() { + return { + canIUseGetUserProfile: canIUseGetUserProfile() + }; + }, + + props: { + id: String, + lang: String, + businessId: Number, + sessionFrom: String, + sendMessageTitle: String, + sendMessagePath: String, + sendMessageImg: String, + showMessageCard: Boolean, + appParameter: String, + ariaLabel: String, + openType: String, + getUserProfileDesc: String + }, + externalClasses: ['hover-class'], + methods: { + onGetUserInfo(event) { + this.$emit('getuserinfo', { + detail: event.detail + }); + }, + + onContact(event) { + this.$emit('contact', { + detail: event.detail + }); + }, + + onGetPhoneNumber(event) { + this.$emit('getphonenumber', { + detail: event.detail + }); + }, + + onError(event) { + this.$emit('error', { + detail: event.detail + }); + }, + + onLaunchApp(event) { + this.$emit('launchapp', { + detail: event.detail + }); + }, + + onOpenSetting(event) { + this.$emit('opensetting', { + detail: event.detail + }); + } + + } +}; \ No newline at end of file diff --git a/dist/mixins/link.js b/dist/mixins/link.js new file mode 100644 index 0000000..7a5b442 --- /dev/null +++ b/dist/mixins/link.js @@ -0,0 +1,32 @@ + +module.exports = { + data() { + return {}; + }, + + props: { + url: String, + linkType: { + type: String, + default: 'navigateTo' + } + }, + methods: { + jumpLink(urlKey = 'url') { + const url = this[urlKey]; + + if (url) { + if (this.linkType === 'navigateTo' && getCurrentPages().length > 9) { + uni.redirectTo({ + url + }); + } else { + uni[this.linkType]({ + url + }); + } + } + } + + } +}; \ No newline at end of file diff --git a/dist/mixins/page-scroll.js b/dist/mixins/page-scroll.js new file mode 100644 index 0000000..25b4803 --- /dev/null +++ b/dist/mixins/page-scroll.js @@ -0,0 +1,41 @@ +import { getCurrentPage } from '../common/utils'; +function onPageScroll(event) { + const { + vanPageScroller = [] + } = getCurrentPage(); + vanPageScroller.forEach(scroller => { + if (typeof scroller === 'function') { + // @ts-ignore + scroller(event); + } + }); +} + +module.exports = { + data() { + return {}; + }, + + props: {}, + + beforeMount() { + const page = getCurrentPage(); + + if (Array.isArray(page.vanPageScroller)) { + page.vanPageScroller.push(scroller.bind(this)); + } else { + page.vanPageScroller = typeof page.onPageScroll === 'function' ? [page.onPageScroll.bind(page), scroller.bind(this)] : [scroller.bind(this)]; + } + + page.onPageScroll = onPageScroll; + }, + + destroyed() { + var _a; + + const page = getCurrentPage(); + page.vanPageScroller = ((_a = page.vanPageScroller) === null || _a === void 0 ? void 0 : _a.filter(item => item !== scroller)) || []; + }, + + methods: {} +}; \ No newline at end of file diff --git a/dist/mixins/touch.js b/dist/mixins/touch.js new file mode 100644 index 0000000..4a1869a --- /dev/null +++ b/dist/mixins/touch.js @@ -0,0 +1,47 @@ +// @ts-nocheck +const MIN_DISTANCE = 10; +function getDirection(x, y) { + if (x > y && x > MIN_DISTANCE) { + return 'horizontal'; + } + + if (y > x && y > MIN_DISTANCE) { + return 'vertical'; + } + + return ''; +} + +module.exports = { + data() { + return {}; + }, + + props: {}, + methods: { + resetTouchStatus() { + this.direction = ''; + this.deltaX = 0; + this.deltaY = 0; + this.offsetX = 0; + this.offsetY = 0; + }, + + touchStart(event) { + this.resetTouchStatus(); + const touch = event.touches[0]; + this.startX = touch.clientX; + this.startY = touch.clientY; + }, + + touchMove(event) { + const touch = event.touches[0]; + this.deltaX = touch.clientX - this.startX; + this.deltaY = touch.clientY - this.startY; + this.offsetX = Math.abs(this.deltaX); + this.offsetY = Math.abs(this.deltaY); + this.direction = this.direction || getDirection(this.offsetX, this.offsetY); + } + + } +}; \ No newline at end of file diff --git a/dist/mixins/transition.js b/dist/mixins/transition.js new file mode 100644 index 0000000..dd54629 --- /dev/null +++ b/dist/mixins/transition.js @@ -0,0 +1,156 @@ +// @ts-nocheck +import { requestAnimationFrame } from '../common/utils'; +import { isObj } from '../common/validator'; +const getClassNames = name => ({ + enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`, + 'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`, + leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`, + 'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class` +}); + +export default function () { + return { + data() { + return { + type: '', + inited: false, + display: false + }; + }, + + props: { + customStyle: String, + // @ts-ignore + show: { + type: Boolean, + default: showDefaultValue + }, + // @ts-ignore + duration: { + type: null, + default: 300 + }, + name: { + type: String, + default: 'fade' + } + }, + watch: { + show: { + handler: 'observeShow', + immediate: true + }, + duration: { + handler: 'observeDuration', + immediate: true + } + }, + + mounted() { + if (this.show === true) { + this.observeShow(true, false); + } + }, + + methods: { + observeShow(value, old) { + if (value === old) { + return; + } + + value ? this.enter() : this.leave(); + }, + + enter() { + const { + duration, + name + } = this; + const classNames = getClassNames(name); + const currentDuration = isObj(duration) ? duration.enter : duration; + this.status = 'enter'; + this.$emit('before-enter'); + requestAnimationFrame(() => { + if (this.status !== 'enter') { + return; + } + + this.$emit('enter'); + this.setData({ + inited: true, + display: true, + classes: classNames.enter, + currentDuration + }); + requestAnimationFrame(() => { + if (this.status !== 'enter') { + return; + } + + this.transitionEnded = false; + this.setData({ + classes: classNames['enter-to'] + }); + }); + }); + }, + + leave() { + if (!this.display) { + return; + } + + const { + duration, + name + } = this; + const classNames = getClassNames(name); + const currentDuration = isObj(duration) ? duration.leave : duration; + this.status = 'leave'; + this.$emit('before-leave'); + requestAnimationFrame(() => { + if (this.status !== 'leave') { + return; + } + + this.$emit('leave'); + this.setData({ + classes: classNames.leave, + currentDuration + }); + requestAnimationFrame(() => { + if (this.status !== 'leave') { + return; + } + + this.transitionEnded = false; + setTimeout(() => this.onTransitionEnd(), currentDuration); + this.setData({ + classes: classNames['leave-to'] + }); + }); + }); + }, + + onTransitionEnd() { + if (this.transitionEnded) { + return; + } + + this.transitionEnded = true; + this.$emit(`after-${this.status}`); + const { + show, + display + } = this; + + if (!show && display) { + this.setData({ + display: false + }); + } + } + + } + }; +} \ No newline at end of file diff --git a/dist/wxs/add-unit.wxs b/dist/wxs/add-unit.wxs new file mode 100644 index 0000000..0b80958 --- /dev/null +++ b/dist/wxs/add-unit.wxs @@ -0,0 +1,12 @@ +/* eslint-disable */ +var REGEXP = getRegExp('^-?\d+(\.\d+)?$'); + +function addUnit(value) { + if (value == null) { + return undefined; + } + + return REGEXP.test('' + value) ? value + 'px' : value; +} + +module.exports = addUnit; \ No newline at end of file diff --git a/dist/wxs/array.wxs b/dist/wxs/array.wxs new file mode 100644 index 0000000..7b1517f --- /dev/null +++ b/dist/wxs/array.wxs @@ -0,0 +1,5 @@ +function isArray(array) { + return array && array.constructor === 'Array'; +} + +module.exports.isArray = isArray; \ No newline at end of file diff --git a/dist/wxs/bem.wxs b/dist/wxs/bem.wxs new file mode 100644 index 0000000..b9c81fd --- /dev/null +++ b/dist/wxs/bem.wxs @@ -0,0 +1,52 @@ +/* eslint-disable */ +///////////////////////////////////dist\wxs\array.wxs///////////////////////////////// +function isArray(array) { + return array && array.constructor === 'Array'; +} + +/* eslint-disable */ +///////////////////////////////////dist\wxs\object.wxs///////////////////////////////// +var REGEXP = getRegExp('{|}|"', 'g'); + +function keys(obj) { + return JSON.stringify(obj).replace(REGEXP, '').split(',').map(function (item) { + return item.split(':')[0]; + }); +} + +var PREFIX = 'van-'; + +function join(name, mods) { + name = PREFIX + name; + mods = mods.map(function (mod) { + return name + '--' + mod; + }); + mods.unshift(name); + return mods.join(' '); +} + +function traversing(mods, conf) { + if (!conf) { + return; + } + + if (typeof conf === 'string' || typeof conf === 'number') { + mods.push(conf); + } else if (isArray(conf)) { + conf.forEach(function (item) { + traversing(mods, item); + }); + } else if (typeof conf === 'object') { + keys(conf).forEach(function (key) { + conf[key] && mods.push(key); + }); + } +} + +function bem(name, conf) { + var mods = []; + traversing(mods, conf); + return join(name, mods); +} + +module.exports = bem; \ No newline at end of file diff --git a/dist/wxs/memoize.wxs b/dist/wxs/memoize.wxs new file mode 100644 index 0000000..6afde74 --- /dev/null +++ b/dist/wxs/memoize.wxs @@ -0,0 +1,52 @@ +/** + * Simple memoize + * wxs doesn't support fn.apply, so this memoize only support up to 2 args + */ + +/* eslint-disable */ +function isPrimitive(value) { + var type = typeof value; + return type === 'boolean' || type === 'number' || type === 'string' || type === 'undefined' || value === null; +} // mock simple fn.call in wxs + + +function call(fn, args) { + if (args.length === 2) { + return fn(args[0], args[1]); + } + + if (args.length === 1) { + return fn(args[0]); + } + + return fn(); +} + +function serializer(args) { + if (args.length === 1 && isPrimitive(args[0])) { + return args[0]; + } + + var obj = {}; + + for (var i = 0; i < args.length; i++) { + obj['key' + i] = args[i]; + } + + return JSON.stringify(obj); +} + +function memoize(fn) { + var cache = {}; + return function () { + var key = serializer(arguments); + + if (cache[key] === undefined) { + cache[key] = call(fn, arguments); + } + + return cache[key]; + }; +} + +module.exports = memoize; \ No newline at end of file diff --git a/dist/wxs/object.wxs b/dist/wxs/object.wxs new file mode 100644 index 0000000..431f623 --- /dev/null +++ b/dist/wxs/object.wxs @@ -0,0 +1,10 @@ +/* eslint-disable */ +var REGEXP = getRegExp('{|}|"', 'g'); + +function keys(obj) { + return JSON.stringify(obj).replace(REGEXP, '').split(',').map(function (item) { + return item.split(':')[0]; + }); +} + +module.exports.keys = keys; \ No newline at end of file diff --git a/dist/wxs/style.wxs b/dist/wxs/style.wxs new file mode 100644 index 0000000..c8f4877 --- /dev/null +++ b/dist/wxs/style.wxs @@ -0,0 +1,45 @@ +/* eslint-disable */ + +/* eslint-disable */ +///////////////////////////////////dist\wxs\object.wxs///////////////////////////////// +var REGEXP = getRegExp('{|}|"', 'g'); + +function keys(obj) { + return JSON.stringify(obj).replace(REGEXP, '').split(',').map(function (item) { + return item.split(':')[0]; + }); +} + +///////////////////////////////////dist\wxs\array.wxs///////////////////////////////// +function isArray(array) { + return array && array.constructor === 'Array'; +} + +function kebabCase(word) { + var newWord = word.replace(getRegExp("[A-Z]", 'g'), function (i) { + return '-' + i; + }).toLowerCase(); + return newWord; +} + +function style(styles) { + if (isArray(styles)) { + return styles.filter(function (item) { + return item != null && item !== ''; + }).map(function (item) { + return style(item); + }).join(';'); + } + + if ('Object' === styles.constructor) { + return keys(styles).filter(function (key) { + return styles[key] != null && styles[key] !== ''; + }).map(function (key) { + return [kebabCase(key), [styles[key]]].join(':'); + }).join(';'); + } + + return styles; +} + +module.exports = style; \ No newline at end of file diff --git a/dist/wxs/utils.wxs b/dist/wxs/utils.wxs new file mode 100644 index 0000000..df59b31 --- /dev/null +++ b/dist/wxs/utils.wxs @@ -0,0 +1,128 @@ +/* eslint-disable */ +///////////////////////////////////dist\wxs\array.wxs///////////////////////////////// + +/* eslint-disable */ +///////////////////////////////////dist\wxs\bem.wxs///////////////////////////////// +function isArray(array) { + return array && array.constructor === 'Array'; +} + +/* eslint-disable */ +///////////////////////////////////dist\wxs\object.wxs///////////////////////////////// +var REGEXP = getRegExp('{|}|"', 'g'); + +function keys(obj) { + return JSON.stringify(obj).replace(REGEXP, '').split(',').map(function (item) { + return item.split(':')[0]; + }); +} + +var PREFIX = 'van-'; + +function join(name, mods) { + name = PREFIX + name; + mods = mods.map(function (mod) { + return name + '--' + mod; + }); + mods.unshift(name); + return mods.join(' '); +} + +function traversing(mods, conf) { + if (!conf) { + return; + } + + if (typeof conf === 'string' || typeof conf === 'number') { + mods.push(conf); + } else if (isArray(conf)) { + conf.forEach(function (item) { + traversing(mods, item); + }); + } else if (typeof conf === 'object') { + keys(conf).forEach(function (key) { + conf[key] && mods.push(key); + }); + } +} + +function bem(name, conf) { + var mods = []; + traversing(mods, conf); + return join(name, mods); +} + +module.exports = bem; + +/** + * Simple memoize + * wxs doesn't support fn.apply, so this memoize only support up to 2 args + */ + +/* eslint-disable */ +///////////////////////////////////dist\wxs\memoize.wxs///////////////////////////////// +function isPrimitive(value) { + var type = typeof value; + return type === 'boolean' || type === 'number' || type === 'string' || type === 'undefined' || value === null; +} // mock simple fn.call in wxs + + +function call(fn, args) { + if (args.length === 2) { + return fn(args[0], args[1]); + } + + if (args.length === 1) { + return fn(args[0]); + } + + return fn(); +} + +function serializer(args) { + if (args.length === 1 && isPrimitive(args[0])) { + return args[0]; + } + + var obj = {}; + + for (var i = 0; i < args.length; i++) { + obj['key' + i] = args[i]; + } + + return JSON.stringify(obj); +} + +function memoize(fn) { + var cache = {}; + return function () { + var key = serializer(arguments); + + if (cache[key] === undefined) { + cache[key] = call(fn, arguments); + } + + return cache[key]; + }; +} + +module.exports = memoize; + +/* eslint-disable */ +///////////////////////////////////dist\wxs\add-unit.wxs///////////////////////////////// +var REGEXP = getRegExp('^-?\d+(\.\d+)?$'); + +function addUnit(value) { + if (value == null) { + return undefined; + } + + return REGEXP.test('' + value) ? value + 'px' : value; +} + +module.exports = addUnit; +module.exports = { + bem: memoize(bem), + memoize: memoize, + addUnit: addUnit +}; \ No newline at end of file diff --git a/pages.json b/pages.json index a512c24..3dda68e 100644 --- a/pages.json +++ b/pages.json @@ -268,7 +268,8 @@ { "path": "pages/life/tempList/index", "style": { - "navigationBarTitleText": "运费模板列表" + "navigationBarTitleText": "运费模板列表", + "enablePullDownRefresh": true } }, { diff --git a/pages/demandHall/index.vue b/pages/demandHall/index.vue index 1037e82..d77fdc1 100644 --- a/pages/demandHall/index.vue +++ b/pages/demandHall/index.vue @@ -627,7 +627,7 @@ image{ border-bottom: 2rpx solid #EEEEEE; } .title-box .title{ - width: 550rpx; + width: 500rpx; } .title-box .price{ margin: 0; diff --git a/pages/life/addGoods/index.vue b/pages/life/addGoods/index.vue index 088120a..e6ac494 100644 --- a/pages/life/addGoods/index.vue +++ b/pages/life/addGoods/index.vue @@ -156,7 +156,7 @@ - + × @@ -182,7 +182,7 @@ slider_image: [] ,// 轮播图 description: '', //商品详情富文本 tempId: 1, //运费方案 - temp: '全国包邮', + temp: '默认免邮', attrs: [ // 单规格一个,多规格多个 { pic: '', //"规格图片 --可选", @@ -206,19 +206,6 @@ } }, onLoad() { - // var arr = [ - // {value: "颜色", detail: ["红"]}, - // {value: "尺寸", detail: ["29cm", "30cm"]} - // ] - // let result = arr.reduce((res, item) => { - // return item.detail.reduce((list, ci) => { - // let nobj = {[item.value]: ci} - // let narr = res.length ? res.map(r => ({...r, ...nobj})) : [nobj] - // return list.concat(narr) - // }, []) - // }, []) - // console.log(result) - this.id = this.$yroute.query.id || '' if(this.id){ uni.setNavigationBarTitle({ @@ -244,12 +231,6 @@ this.attrs[0].price = info.price this.attrs[0].stock = info.stock } - - // this.batchData.titleStr = strArr.join('/') - // this.$set(this.batchData,'titleStr',strArr.join('/')) - // this.$set(this.batchData,'attrArr',attrArr) - }).then(()=>{ - // this.getFormatAttr() }) } else{ console.log('新增') @@ -307,7 +288,6 @@ }, delAttr(i){ this.attrArr.splice(i,1) - // this.setBatchData(this.attrArr) this.getFormatAttr() }, addOption(){ @@ -346,6 +326,7 @@ this.addOptionsDialog = false this.maskShow = false }, + //属性数据接口 getFormatAttr(){ let data = { attrs: this.items, productId: this.id || 0 } getFormatAttr(data).then((res)=>{ @@ -363,13 +344,13 @@ } }) }, - //批量设置数据 + //属性设置数据 setBatchData(arr){ var titleArr = [] - // for (var i in arr) { - // titleArr.push(arr[i].value) - // } - // var titleStr = titleArr.join('/') + for (var i in arr) { + titleArr.push(arr[i].value) + } + var titleStr = titleArr.join('/') var attrArr = this.setData(arr) var branchList = [] var hash = {} @@ -395,7 +376,6 @@ for (var i in attrArr) { tmp.push(attrArr[i].detail) } - console.log(tmp,'tmp') function cartesianProductOf() { return Array.prototype.reduce.call(arguments, function (a, b) { var ret = []; diff --git a/pages/life/tempList/index.vue b/pages/life/tempList/index.vue index f4a55d4..7d0d736 100644 --- a/pages/life/tempList/index.vue +++ b/pages/life/tempList/index.vue @@ -27,6 +27,9 @@ }, mounted(){ + }, + onPullDownRefresh(){ + this.getTempList() }, methods:{ choseTemp(item){ @@ -49,6 +52,7 @@ getTempList().then((res)=>{ // console.log(res) this.tempList = res.data.content + uni.stopPullDownRefresh() }) }, toTemp(){ diff --git a/pages/shop/GoodsCon/index.vue b/pages/shop/GoodsCon/index.vue index 9ce738f..5e0a7d1 100644 --- a/pages/shop/GoodsCon/index.vue +++ b/pages/shop/GoodsCon/index.vue @@ -420,7 +420,7 @@ export default { }) getProductDetail(that.id, from) .then(res => { - res.data.storeInfo.description = res.data.storeInfo.description.replace(/\