From 3bc055f2ee9e813db0f08c5aefc4799be943f77f Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期一, 23 十二月 2024 19:38:57 +0800 Subject: [PATCH] 添加选择机构功能 --- pages/home/home.vue | 89 +++++++++++++- uni_modules/uni-section/components/uni-section/uni-section.vue | 139 +++++++++++++++++++++++ uni_modules/uni-section/readme.md | 33 +++++ pages.json | 13 + uni_modules/uni-section/changelog.md | 0 App.vue | 4 uni_modules/uni-section/package.json | 79 +++++++++++++ 7 files changed, 347 insertions(+), 10 deletions(-) diff --git a/App.vue b/App.vue index a9df53f..0864064 100644 --- a/App.vue +++ b/App.vue @@ -218,6 +218,10 @@ height: 60upx; text-align: center; line-height: 60upx; + } + + .uni-app--showtopwindow [data-page="pages/home/home"] uni-page-head { + display: none; } .text-light { diff --git a/pages.json b/pages.json index a20e604..9c5ca09 100644 --- a/pages.json +++ b/pages.json @@ -1,4 +1,12 @@ -{ +{ + // "easycom": { + // "autoscan": true, + // "custom": { + // // uni-ui 瑙勫垯濡備笅閰嶇疆 + // "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue" + // } + // }, + "pages": [ //pages鏁扮粍涓涓�椤硅〃绀哄簲鐢ㄥ惎鍔ㄩ〉锛屽弬鑰冿細https://uniapp.dcloud.io/collocation/pages { "path": "pages/login/login", @@ -9,7 +17,8 @@ { "path": "pages/home/home", "style": { - "navigationBarTitleText": "涓� 椤�" + "navigationBarTitleText": "涓� 椤�", + "navigationStyle": "custom" } }, { diff --git a/pages/home/home.vue b/pages/home/home.vue index ab9a213..a7b8ab3 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -1,6 +1,22 @@ <template> <view> + <view class="box-bg"> + <uni-nav-bar shadow left-icon="bars" title="涓婚〉" @clickLeft="selectLoc()" /> + </view> <scroll-view scroll-y class="page"> + <view> + <uni-drawer ref="showLeft" mode="left" :width="320"> + <view> + <view> + <uni-section title="鏈烘瀯閫夋嫨" type="line"></uni-section> + </view> + <uni-list v-for="(item, index) in hosts" :key="item.id"> + <uni-list-item :title="item.name" clickable @click="itemClick(item)"></uni-list-item> + </uni-list> + </view> + + </uni-drawer> + </view> <view class="nav-list"> <navigator hover-class='none' :url="'/pages' + item.url" class="nav-li" navigateTo :class="'bg-'+item.color" :style="[{animation: 'show ' + ((index+1)*0.2+1) + 's 1'}]" @@ -22,9 +38,9 @@ baseUrl: '', token: '', icon: '', + hosts: [], elements: [], - elements2: [ - { + elements2: [{ title: '缁勬墭鍏ュ簱', name: 'pakin', color: 'cyan', @@ -124,21 +140,73 @@ }, ], - colorList: ['cyan','blue','mauve','pink','brown','red','orange','yellow','olive','olive','green','grey' ] + colorList: ['cyan', 'blue', 'mauve', 'pink', 'brown', 'red', 'orange', 'yellow', 'olive', 'olive', 'green', + 'grey' + ] }; }, + onShow() { this.baseUrl = uni.getStorageSync('baseUrl'); this.token = uni.getStorageSync('token'); + + this.getCurrentHosts() this.getAuth() + }, - methods: { + + + methods: { + + + selectLoc() { + this.$refs['showLeft'].open() + }, + + closeDrawer() { + this.$refs['showLeft'].close() + + }, + + itemClick(event) { + if (event != null && event.id != null) { + this.$refs['showLeft'].close() + uni.setStorageSync('hostId', event.id) + } + }, + + getCurrentHosts() { + let that = this + uni.request({ + url: that.baseUrl + '/pda/current/host', + data: {}, + header: { + 'token': uni.getStorageSync('token') + }, + method: "GET", + success(res) { + let result = res.data + if (result.code == 200) { + that.hosts = result.data; + if (uni.getStorageSync('hostId') == null || uni.getStorageSync('hostId') == '') { + that.$refs['showLeft'].open() + } + } + }, + fail(res) { + + } + }) + }, + getAuth() { let that = this uni.request({ url: that.baseUrl + '/menu/pda/auth', data: {}, - header: { 'token': uni.getStorageSync('token') }, + header: { + 'token': uni.getStorageSync('token') + }, method: 'POST', success(res) { res = res.data @@ -179,7 +247,7 @@ url: '../login/login' }); }, 1000); - } else if(res.status === 404) { + } else if (res.status === 404) { that.elements = that.elements2 // uni.showToast({ // title: '榛樿涓婚〉', @@ -199,8 +267,9 @@ } }) }, + getIcon(e) { - const ways = ['pakin','orderPakin','orderPutOn'] + const ways = ['pakin', 'orderPakin', 'orderPutOn'] if (ways.includes(e)) { this.icon = 'pullup' } @@ -209,7 +278,11 @@ } </script> -<style> +<style> + .uni-section{ + margin-top: 0rpx; + } + .page { height: 100vh; } diff --git a/uni_modules/uni-section/changelog.md b/uni_modules/uni-section/changelog.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/uni_modules/uni-section/changelog.md diff --git a/uni_modules/uni-section/components/uni-section/uni-section.vue b/uni_modules/uni-section/components/uni-section/uni-section.vue new file mode 100644 index 0000000..d022420 --- /dev/null +++ b/uni_modules/uni-section/components/uni-section/uni-section.vue @@ -0,0 +1,139 @@ +<template> + <view class="uni-section" nvue> + <view v-if="type" class="uni-section__head"> + <view :class="type" class="uni-section__head-tag" /> + </view> + <view class="uni-section__content"> + <text :class="{'distraction':!subTitle}" class="uni-section__content-title">{{ title }}</text> + <text v-if="subTitle" class="uni-section__content-sub">{{ subTitle }}</text> + </view> + <slot /> + </view> +</template> + +<script> + + /** + * Section 鏍囬鏍� + * @description 鏍囬鏍� + * @property {String} type = [line|circle] 鏍囬瑁呴グ绫诲瀷 + * @value line 绔栫嚎 + * @value circle 鍦嗗舰 + * @property {String} title 涓绘爣棰� + * @property {String} subTitle 鍓爣棰� + */ + + export default { + name: 'UniSection', + props: { + type: { + type: String, + default: '' + }, + title: { + type: String, + default: '' + }, + subTitle: { + type: String, + default: '' + } + }, + data() { + return {} + }, + watch: { + title(newVal) { + if (uni.report && newVal !== '') { + uni.report('title', newVal) + } + } + }, + methods: { + onClick() { + this.$emit('click') + } + } + } +</script> +<style lang="scss" scoped> + .uni-section { + position: relative; + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + margin-top: 10px; + flex-direction: row; + align-items: center; + padding: 0 10px; + height: 50px; + background-color: $uni-bg-color-grey; + /* #ifdef APP-NVUE */ + // border-bottom-color: $uni-border-color; + // border-bottom-style: solid; + // border-bottom-width: 0.5px; + /* #endif */ + font-weight: normal; + } + /* #ifndef APP-NVUE */ + // .uni-section:after { + // position: absolute; + // bottom: 0; + // right: 0; + // left: 0; + // height: 1px; + // content: ''; + // -webkit-transform: scaleY(.5); + // transform: scaleY(.5); + // background-color: $uni-border-color; + // } + /* #endif */ + + .uni-section__head { + flex-direction: row; + justify-content: center; + align-items: center; + margin-right: 10px; + } + + .line { + height: 15px; + background-color: $uni-text-color-disable; + border-radius: 5px; + width: 3px; + } + + .circle { + width: 8px; + height: 8px; + border-top-right-radius: 50px; + border-top-left-radius: 50px; + border-bottom-left-radius: 50px; + border-bottom-right-radius: 50px; + background-color: $uni-text-color-disable; + } + + .uni-section__content { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + flex-direction: column; + flex: 1; + color: $uni-text-color; + } + + .uni-section__content-title { + font-size: $uni-font-size-base; + color: $uni-text-color; + } + + .distraction { + flex-direction: row; + align-items: center; + } + + .uni-section__content-sub { + font-size: $uni-font-size-sm; + color: $uni-text-color-grey; + } +</style> diff --git a/uni_modules/uni-section/package.json b/uni_modules/uni-section/package.json new file mode 100644 index 0000000..36a4e81 --- /dev/null +++ b/uni_modules/uni-section/package.json @@ -0,0 +1,79 @@ +{ + "id": "uni-section", + "displayName": "Section 鏍囬鏍�", + "version": "0.0.1", + "description": "", + "keywords": [ + "" + ], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, + "dcloudext": { + "category": [ + "鍓嶇缁勪欢", + "閫氱敤缁勪欢" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "鏃�", + "data": "鏃�", + "permissions": "鏃�" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "App": { + "app-vue": "u", + "app-nvue": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "寰俊娴忚鍣�(Android)": "u", + "QQ娴忚鍣�(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "灏忕▼搴�": { + "寰俊": "u", + "闃块噷": "u", + "鐧惧害": "u", + "瀛楄妭璺冲姩": "u", + "QQ": "u" + }, + "蹇簲鐢�": { + "鍗庝负": "u", + "鑱旂洘": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-section/readme.md b/uni_modules/uni-section/readme.md new file mode 100644 index 0000000..ec02c52 --- /dev/null +++ b/uni_modules/uni-section/readme.md @@ -0,0 +1,33 @@ + + +## Section 鏍囬鏍� +> 浠g爜鍧楋細 `uSection` + + +鏍囬鏍忥紝鐢ㄤ簬鏄剧ず鏍囬銆� + +### 瀹夎鏂瑰紡 + +鏈粍浠剁鍚圼easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)瑙勮寖锛宍HBuilderX 2.5.5`璧凤紝鍙渶灏嗘湰缁勪欢瀵煎叆椤圭洰锛屽湪椤甸潰`template`涓嵆鍙洿鎺ヤ娇鐢紝鏃犻渶鍦ㄩ〉闈腑`import`鍜屾敞鍐宍components`銆� + +濡傞渶閫氳繃`npm`鏂瑰紡浣跨敤`uni-ui`缁勪欢锛屽彟瑙佹枃妗o細[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55) + +### 鍩烘湰鐢ㄦ硶 + +鍦� ``template`` 涓娇鐢ㄧ粍浠� + +```html +<uni-section title="鍙湁涓绘爣棰�"></uni-section> +<uni-section title="绔栫嚎瑁呴グ" sub-title="鍓爣棰�" type="line"></uni-section> +<uni-section title="鍦嗗舰瑁呴グ" sub-title="鍓爣棰�" type="circle"></uni-section> +``` + +## API + +### Section Props + +|灞炴�у悕 |绫诲瀷 |榛樿鍊� |璇存槑 | +|:-: |:-: |:-: |:-: | +|type |String |- |鏍囬瑁呴グ绫诲瀷 锛屽彲閫夊�硷細line锛堢珫绾匡級銆乧ircle锛堝渾褰級| +|title |String |- |涓绘爣棰� | +|sub-title |String |- |鍓爣棰� | -- Gitblit v1.9.1