Commit 85794c00 authored by 李俊赕's avatar 李俊赕

新增card-type

parent ff6e3f4b
...@@ -8,18 +8,19 @@ ...@@ -8,18 +8,19 @@
</view> </view>
<view class="u-menu-wrap"> <view class="u-menu-wrap">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop" <scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop"
:scroll-into-view="itemId"> :scroll-into-view="itemId">
<view v-for="(item,index) in tabbar" :key="index" class="u-tab-item" :class="[current == index ? 'u-tab-item-active' : '']" <view v-for="(item,index) in tabbar" :key="index" class="u-tab-item"
@tap.stop="swichMenu(index)"> :class="[current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text> <text class="u-line-1">{{item.name}}</text>
</view> </view>
</scroll-view> </scroll-view>
<scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll"> <scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box"
@scroll="rightScroll">
<!-- <form-com :item="tabbar"></form-com> --> <!-- <form-com :item="tabbar"></form-com> -->
<u-form :model="form" ref="uForm"> <u-form :model="form" ref="uForm">
<template v-for="(groupItem,index) in tabbar"> <template v-for="(groupItem,index) in tabbar">
<view class="class-item" :key="index"> <view class="class-item" :key="index">
<view class="title" >{{groupItem.name}}</view> <view class="title">{{groupItem.name}}</view>
<view class="class-bd"> <view class="class-bd">
<u-form-item :label-width="0" :required="groupItem.required" <u-form-item :label-width="0" :required="groupItem.required"
v-for="(item,itemIndex) in groupItem.foods" :key="itemIndex"> v-for="(item,itemIndex) in groupItem.foods" :key="itemIndex">
...@@ -34,7 +35,7 @@ ...@@ -34,7 +35,7 @@
</template> </template>
</u-form> </u-form>
<!-- <xh-input></xh-input> --> <!-- <xh-input></xh-input> -->
<!-- <view class="page-view"> <!-- <view class="page-view">
<view class="class-item" :id="'item' + index" v-for="(item , index) in tabbar" :key="index"> <view class="class-item" :id="'item' + index" v-for="(item , index) in tabbar" :key="index">
<view class="item-title"> <view class="item-title">
<text>{{item.name}}</text> <text>{{item.name}}</text>
...@@ -53,10 +54,8 @@ ...@@ -53,10 +54,8 @@
</template> </template>
<script> <script>
import classifyData from '@/common/classify.data.js'; import classifyData from '@/common/classify.data.js';
// import allComponents from '@/components/createCom/index.js'
// import XhInput from '@/components/createCom/XhInput.vue'
// import formCom from './components/formCom.vue' // import formCom from './components/formCom.vue'
import XhInput from '@/components/createCom/XhInput.vue' import XhInput from '@/components/createCom/XhInput.vue'
export default { export default {
data() { data() {
return { return {
...@@ -71,17 +70,17 @@ ...@@ -71,17 +70,17 @@
arr: [], arr: [],
scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度 scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
timer: null, // 定时器 timer: null, // 定时器
} }
}, },
components: { components: {
'xh-input': XhInput, 'xh-input': XhInput,
}, },
created(){ created() {
// console.log(allComponents,'allComponents') // console.log(allComponents,'allComponents')
}, },
onLoad() { onLoad() {
}, },
onReady() { onReady() {
this.getMenuItemTop() this.getMenuItemTop()
...@@ -89,12 +88,12 @@ ...@@ -89,12 +88,12 @@
methods: { methods: {
// 点击左边的栏目切换 // 点击左边的栏目切换
async swichMenu(index) { async swichMenu(index) {
if(this.arr.length == 0) { if (this.arr.length == 0) {
await this.getMenuItemTop(); await this.getMenuItemTop();
} }
if (index == this.current) return; if (index == this.current) return;
this.scrollRightTop = this.oldScrollTop; this.scrollRightTop = this.oldScrollTop;
this.$nextTick(function(){ this.$nextTick(function() {
this.scrollRightTop = this.arr[index]; this.scrollRightTop = this.arr[index];
this.current = index; this.current = index;
this.leftMenuStatus(index); this.leftMenuStatus(index);
...@@ -152,11 +151,11 @@ ...@@ -152,11 +151,11 @@
let selectorQuery = uni.createSelectorQuery(); let selectorQuery = uni.createSelectorQuery();
selectorQuery.selectAll('.class-item').boundingClientRect((rects) => { selectorQuery.selectAll('.class-item').boundingClientRect((rects) => {
// 如果节点尚未生成,rects值为[](因为用selectAll,所以返回的是数组),循环调用执行 // 如果节点尚未生成,rects值为[](因为用selectAll,所以返回的是数组),循环调用执行
if(!rects.length) { if (!rects.length) {
setTimeout(() => { setTimeout(() => {
this.getMenuItemTop(); this.getMenuItemTop();
}, 10); }, 10);
return ; return;
} }
rects.forEach((rect) => { rects.forEach((rect) => {
// 这里减去rects[0].top,是因为第一项顶部可能不是贴到导航栏(比如有个搜索框的情况) // 这里减去rects[0].top,是因为第一项顶部可能不是贴到导航栏(比如有个搜索框的情况)
...@@ -166,18 +165,18 @@ ...@@ -166,18 +165,18 @@
}).exec() }).exec()
}) })
}, },
// 右边菜单滚动 // 右边菜单滚动
async rightScroll(e) { async rightScroll(e) {
this.oldScrollTop = e.detail.scrollTop; this.oldScrollTop = e.detail.scrollTop;
if(this.arr.length == 0) { if (this.arr.length == 0) {
await this.getMenuItemTop(); await this.getMenuItemTop();
} }
if(this.timer) return ; if (this.timer) return;
if(!this.menuHeight) { if (!this.menuHeight) {
await this.getElRect('menu-scroll-view', 'menuHeight'); await this.getElRect('menu-scroll-view', 'menuHeight');
} }
setTimeout(() => { // 节流 this.timer = setTimeout(() => { // 节流
this.timer = null; this.timer = null;
// scrollHeight为右边菜单垂直中点位置 // scrollHeight为右边菜单垂直中点位置
let scrollHeight = e.detail.scrollTop + this.menuHeight / 2; let scrollHeight = e.detail.scrollTop + this.menuHeight / 2;
...@@ -187,7 +186,7 @@ ...@@ -187,7 +186,7 @@
// 如果不存在height2,意味着数据循环已经到了最后一个,设置左边菜单为最后一项即可 // 如果不存在height2,意味着数据循环已经到了最后一个,设置左边菜单为最后一项即可
if (!height2 || scrollHeight >= height1 && scrollHeight < height2) { if (!height2 || scrollHeight >= height1 && scrollHeight < height2) {
this.leftMenuStatus(i); this.leftMenuStatus(i);
return ; return;
} }
} }
}, 10) }, 10)
......
...@@ -26,11 +26,11 @@ let baseOptions = { ...@@ -26,11 +26,11 @@ let baseOptions = {
let uploader = new request(baseOptions); let uploader = new request(baseOptions);
// 添加获取七牛云token的方法 // 添加获取七牛云token的方法
uploader.getQnToken = function() { uploader.getQnToken = function(data) {
//该地址需要开发者自行配置(每个后台的接口风格都不一样) //该地址需要开发者自行配置(每个后台的接口风格都不一样)
// console.log(uploader.get,'uploader.get') // console.log(uploader.get,'uploader.get')
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uploader.post(baseOptions.qiniuUploadUrl).then(data => { uploader.post(baseOptions.qiniuUploadUrl,data).then(data => {
/* /*
*接口返回参数: *接口返回参数:
*visitPrefix:访问文件的域名 *visitPrefix:访问文件的域名
......
...@@ -82,9 +82,13 @@ export default class fileUpload extends request { ...@@ -82,9 +82,13 @@ export default class fileUpload extends request {
} }
} }
let qnRes = this.qiniuTokenObj let qnRes = this.qiniuTokenObj
if(!qnRes){ if(!qnRes || qnRes.cardType !== requestInfo.cardType){
qnRes = await this.getQnToken() let params = {type:requestInfo.cardType || ''}
this.qiniuTokenObj = qnRes qnRes = await this.getQnToken(params)
this.qiniuTokenObj = {
cardType:'',
...qnRes
}
} }
const parmas = JSON.parse(JSON.stringify(qnRes)) const parmas = JSON.parse(JSON.stringify(qnRes))
parmas.visitPrefix = '' parmas.visitPrefix = ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment