合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
### 搜索记录,历史记录 > 点击搜索 ``` for (var i = 0; i < this.SearchRecordArr.length; i++) { if (this.SearchRecordArr[i] == this.keyword) { this.SearchRecordArr.splice(i, 1); } } this.SearchRecordArr.unshift(this.keyword); uni.setStorageSync('SearchRecordArr', JSON.stringify(this.SearchRecordArr)); ``` > 初始化时加载数据 ``` if (uni.getStorageSync('SearchRecordArr')) { this.SearchRecordArr = JSON.parse(uni.getStorageSync('SearchRecordArr')); } ``` ### 头像上传 ``` <view class="more-content" @click="upload"> <image :src="avatar" mode=""></image> <text class="iconfont icon-more more"></text> </view> ``` ``` /** * 上传头像 */ upload() { let users = this.$storage.getJson("users"); let that = this; uni.chooseImage({ count: 1, success: (chooseImageRes) => { const tempFilePaths = chooseImageRes.tempFilePaths; uni.uploadFile({ url: config.uni_app_web_api_url + '' + '/ucenter/avatar', filePath: tempFilePaths[0], name: 'file', header: { "Auth-Token": users.token }, success: (uploadFileRes) => { let res = JSON.parse(uploadFileRes.data); that.avatar = res.data; } }); } }); }, ``` ### 省市级 ```vue <view> <lb-picker ref="picker" v-model="area" mode="multiSelector" :list="list" :level="3" @change="handleChange" @confirm="handleConfirm" @cancel="handleCancel"></lb-picker> <input @click="handleTap('picker')" type="text" class="uni-input" :value="area_name" disabled="true" placeholder="请选择您所在地区"/> </view> ``` > 引入城市数据 `import areaData from"@/common/area-data-min"` > 引入选择器 `import LbPicker from '@/components/lb-picker'` ``` handleTap(picker) { this.$refs[picker].show(); }, handleChange(item) { //console.log('change::', item) }, handleConfirm(data) { // this.province = data.value[0]; // this.county = data.value[1]; // this.city = data.value[2] != undefined ? data.value[2] : 0; let arr = []; for (let i in data.item) { arr.push(data.item[i].label); } // console.log(arr); this.province = arr[0]; this.city = arr[1]; this.county = arr[2] != undefined ? arr[2] : 0; if (arr.length > 0) { this.area_name = arr.join(","); } this.areaCode = data.value; }, handleCancel(item) { //console.log('cancel::', item) }, ```