| | |
| | | export default { |
| | | onLaunch: function() { |
| | | console.log('App Launch') |
| | | if(!uni.getStorageSync('openId') || !uni.getStorageSync('token')){ |
| | | uni.redirectTo({ |
| | | url:'/pages/login/index' |
| | | }) |
| | | } |
| | | // if(!uni.getStorageSync('openId') || !uni.getStorageSync('token')){ |
| | | // uni.redirectTo({ |
| | | // url:'/pages/login/index' |
| | | // }) |
| | | // } |
| | | }, |
| | | onShow: function() { |
| | | console.log('App Show') |
| | |
| | | return request('/user/wxLogin',data,'POST') |
| | | } |
| | | |
| | | // 用户信息 |
| | | export function getUserInfo(){ |
| | | return request('/api/user/getUser',{},'GET') |
| | | } |
| | | |
| | | // 修改用户信息 |
| | | export function setUserInfo(data){ |
| | | return request('/api/user/editUser',data,'POST') |
| | | } |
| | | |
| | | //微信支付 |
| | | export function wxPayApi(data){ |
| | | return request('/pay/service/wxPay',data,'POST') |
| | | } |
| | | |
| | | //水卡充值 |
| | | //水卡充值* |
| | | export function rechargeApi(data){ |
| | | return request('/rechargeRecords/fees',data,'POST') |
| | | } |
| | | |
| | | // 设备列表 |
| | | export function getFacitily(data) { |
| | | return request('/api/user/searchFacility', data, 'POST') |
| | | } |
| | | |
| | | // 取水记录 |
| | | export function getqushuiRecord(data) { |
| | | return request('/api/user/searchPaymentRecords', data, 'POST') |
| | | } |
| | | |
| | | // 充值记录 |
| | | export function getrechargeRecord(data) { |
| | | return request('/api/user/searchRechargeRecords', data, 'POST') |
| | | } |
| | |
| | | {"path": "pages/index/index"}, |
| | | {"path": "pages/login/index"}, |
| | | {"path": "pages/user/index"}, |
| | | {"path": "pages/userSet/index"}, |
| | | {"path": "pages/device/index"}, |
| | | {"path": "pages/recharge/index"}, |
| | | {"path": "pages/record/qushui"}, |
| | | {"path": "pages/record/shuiliang"}, |
| | | {"path": "pages/record/chongzhi"} |
| | | ], |
| | | "tabBar": { |
| | |
| | | "globalStyle": { |
| | | "navigationBarTextStyle": "black", |
| | | "navigationBarBackgroundColor": "#F8F8F8", |
| | | "navigationStyle": "custom" |
| | | "navigationStyle": "custom", |
| | | "onReachBottomDistance": 100 |
| | | } |
| | | } |
| | |
| | | <template> |
| | | <view class="device"> |
| | | <Navbar title="设备列表"></Navbar> |
| | | <view class="content"> |
| | | <view class="list"> |
| | | <block v-for="(item,index) in facitilyList" :key="index"> |
| | | <view class="item"> |
| | | <view class="item-img"> |
| | | <image v-if="item.facilityUrl" :src="BASE_URL + '/upload' + item.facilityUrl" alt='' mode="aspectFit"></image> |
| | | <image v-else src="../../static/images/facilityImg.svg" alt='' mode="aspectFit"></image> |
| | | </view> |
| | | <view class="item-info"> |
| | | <view class="info-name"> |
| | | <view class="name">{{item.facilityName}}</view> |
| | | <view class="btn" @click="handleQushui(item.id)">取水</view> |
| | | </view> |
| | | <view class="info-addr" @click="openMap(item.lat,item.lon)"> |
| | | <text class="addr-text">地址:{{item.address}}</text> |
| | | <view> |
| | | <image src="../../static/images/icon-point.svg" alt=''></image> |
| | | <text>{{item.distanceValue}}km</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </block> |
| | | </view> |
| | | </view> |
| | | <uni-popup ref="qushuiDialog" type="dialog"> |
| | | <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="请输入取水量" |
| | | @confirm="dialogConfirm" |
| | | @close="dialogClose" |
| | | > |
| | | <view> |
| | | <input v-model="qushuiNum" placeholder="请输入取水量(L)" /> |
| | | </view> |
| | | </uni-popup-dialog> |
| | | </uni-popup> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import{ ref, onMounted } from 'vue' |
| | | import Navbar from '../../components/navbar/navbar.vue' |
| | | import { getFacitily } from '@/api/index.js' |
| | | import { BASE_URL } from '../../config/index.js' |
| | | |
| | | const userLocation = ref() |
| | | const facitilyList = ref([]) |
| | | const qushuiDialog = ref() |
| | | const facitilyId = ref() |
| | | const qushuiNum = ref() |
| | | |
| | | const getFacitilyList = () => { |
| | | const data = { |
| | | longitude: userLocation.value?.lon, |
| | | latitude: userLocation.value?.lat, |
| | | limit: 100, |
| | | page: 1 |
| | | } |
| | | getFacitily(data).then(res => { |
| | | if(res.code === 200) { |
| | | facitilyList.value = res.data.list |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 根据经纬度计算距离,根据经纬度计算距离,参数分别为第一点的纬度,经度(用户);第二点的纬度,经度(设备) |
| | | const getDistances = (lat1, lon1, lat2, lon2) => { |
| | | let EARTH_RADIUS = 6378.137;// 地球半径 |
| | | let radLat1 = lat1 * Math.PI / 180.0; //lat1 * Math.PI / 180.0=>弧度计算 |
| | | let radLat2 = lat2 * Math.PI / 180.0; |
| | | let a = radLat1 - radLat2; |
| | | let b = lon1 * Math.PI / 180.0 - lon2 * Math.PI / 180.0; |
| | | let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); |
| | | s = s * EARTH_RADIUS; |
| | | s = Math.round(s * 10000) / 10000;// 输出为公里 |
| | | return { m: s * 1000, km: Number(s.toFixed(2)) } |
| | | // 取水 |
| | | const handleQushui = (id) => { |
| | | facitilyId.value = id |
| | | qushuiDialog.value.open() |
| | | } |
| | | |
| | | // 取消 |
| | | const dialogClose = () => { |
| | | facitilyId.value = '' |
| | | qushuiNum.value = '' |
| | | } |
| | | |
| | | // 确认 |
| | | const dialogConfirm = () => { |
| | | |
| | | } |
| | | |
| | | //打开地图导航 |
| | | const openMap = (lat,lon) => { |
| | | uni.openLocation({ |
| | | latitude: parseFloat(lat), |
| | | longitude: parseFloat(lon), |
| | | scale:18 |
| | | }) |
| | | } |
| | | |
| | | //获取用户位置并存储 |
| | | const storageLocation = () => { |
| | | uni.getLocation({ |
| | | type:'gcj02', |
| | | isHighAccuracy:true, |
| | | success:(res) =>{ |
| | | userLocation.value = { |
| | | lat: res.latitude, |
| | | lon: res.longitude |
| | | } |
| | | uni.setStorageSync('userLocation',JSON.stringify(userLocation.value)) |
| | | }, |
| | | fail:(err) =>{ |
| | | locationToast() |
| | | } |
| | | }) |
| | | } |
| | | //用户拒绝授权 |
| | | const locationToast = () => { |
| | | uni.showModal({ |
| | | title: "请求授权当前位置", |
| | | content: "请求获取您的位置,加载附近饮水设备信息!", |
| | | confirmText: "前往设置", |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | uni.openSetting({ |
| | | success:(res1) =>{ //打开设置成功 |
| | | if (res1.authSetting['scope.userLocation']){ |
| | | setTimeout(() =>{ |
| | | storageLocation() |
| | | },1000) |
| | | } |
| | | }, |
| | | }) |
| | | }else{ |
| | | uni.showToast({ |
| | | title: '请先授权!', |
| | | duration: 2000, |
| | | icon:'none' |
| | | }); |
| | | } |
| | | }, |
| | | }); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | userLocation.value = JSON.parse(uni.getStorageSync('userLocation')) |
| | | const location = uni.getStorageSync('userLocation') |
| | | if(location) { |
| | | userLocation.value = JSON.parse(location) |
| | | getFacitilyList() |
| | | }else{ |
| | | locationToast() |
| | | } |
| | | }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .content{ |
| | | width: 100%; |
| | | height:calc(100vh - 176rpx); |
| | | background:linear-gradient(to top,#FFFFFF,#E8EFFF); |
| | | padding:32rpx 32rpx 100rpx; |
| | | box-sizing: border-box; |
| | | .list{ |
| | | width:100%; |
| | | height:100%; |
| | | overflow: scroll; |
| | | // background-color: #f1ffef; |
| | | .item{ |
| | | height:200rpx; |
| | | width:100%; |
| | | background-color: #FFFFFF; |
| | | border-radius: 24rpx; |
| | | padding:0 20rpx; |
| | | margin-bottom:20rpx; |
| | | box-sizing: border-box; |
| | | display: flex; |
| | | align-items:center; |
| | | .item-img{ |
| | | image{ |
| | | width:130rpx; |
| | | height: 130rpx; |
| | | } |
| | | } |
| | | .item-info{ |
| | | display: flex; |
| | | flex-direction: column; |
| | | margin-left:20rpx; |
| | | justify-content: space-between; |
| | | .info-name{ |
| | | color:#222c35; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | .btn{ |
| | | padding: 10rpx 20rpx; |
| | | background-color: $uni-primary; |
| | | border-radius: 10rpx; |
| | | color: #fff; |
| | | } |
| | | } |
| | | .info-addr{ |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items:center; |
| | | .addr-text{ |
| | | width:340rpx; |
| | | height:80rpx; |
| | | color: #6a6e75; |
| | | font-size:26rpx; |
| | | } |
| | | view{ |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items:center; |
| | | image{ |
| | | width:50rpx; |
| | | height:50rpx; |
| | | } |
| | | text{ |
| | | color: #6a6e75; |
| | | font-size:26rpx; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | |
| | | <template> |
| | | <view class="container" :style="{paddingTop:topHeight + 'rpx'}"> |
| | | <view class="content"> |
| | | <view class="user"> |
| | | <!-- <view class="user"> |
| | | <view class="userImg"> |
| | | <image src="/static/images/login/wx.png" mode="widthFix"></image> |
| | | </view> |
| | | <view class="info"> |
| | | <text class="name">张三</text> |
| | | </view> |
| | | </view> |
| | | </view> --> |
| | | <view class="card"> |
| | | <view class="water"> |
| | | <text>水量:</text> |
| | | <text>750m³</text> |
| | | <view class="water item"> |
| | | <text>剩余水量:</text> |
| | | <text>{{userInfo?.balance}}m³</text> |
| | | </view> |
| | | <view class="by item"> |
| | | <text>总购水量:</text> |
| | | <text>{{userInfo?.sumBuyCount}}m³</text> |
| | | </view> |
| | | <view class="all item"> |
| | | <text>累计水量:</text> |
| | | <text>{{userInfo?.sumUseCount}}m³</text> |
| | | </view> |
| | | <view class="btn"> |
| | | <button type="primary" @click="handleNav('/pages/recharge/index')">充值</button> |
| | | </view> |
| | | </view> |
| | | <view class="near" @click="handleNav('/pages/device/index')"> |
| | | <image src="/static/images/address.png" mode="widthFix"></image> |
| | | <text>附近设备</text> |
| | | </view> |
| | | <view class="domain"> |
| | | <view class="t">功能列表</view> |
| | |
| | | <image src="/static/images/qushui.png"></image> |
| | | <view>取水记录</view> |
| | | </view> |
| | | <view class="item" @click="handleNav('/pages/record/shuiliang')"> |
| | | <image src="/static/images/shuiliang.png"></image> |
| | | <view>水量记录</view> |
| | | </view> |
| | | <view class="item" @click="handleNav('/pages/record/chongzhi')"> |
| | | <image src="/static/images/chongzhi.png"></image> |
| | | <view>充值记录</view> |
| | | </view> |
| | | <view class="item" @click="handleNav()"> |
| | | <image src="/static/images/kefu.png"></image> |
| | | <view>联系客服</view> |
| | | </view> |
| | | </view> |
| | | <view class="near" @click="handleNav('/pages/device/index')"> |
| | | <image src="/static/images/address.png" mode="widthFix"></image> |
| | | <text>附近设备</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | <script setup> |
| | | import { onMounted, ref } from "vue"; |
| | | import { BASE_URL } from '../../config/index.js'; |
| | | import { getUserInfo } from '@/api/index.js' |
| | | |
| | | const topHeight = ref(0) |
| | | const userInfo = ref() |
| | | let userLocation = { |
| | | lat:'', |
| | | lon:'', |
| | |
| | | } |
| | | uni.navigateTo({ |
| | | url: url |
| | | }) |
| | | } |
| | | |
| | | // 获取用户信息 |
| | | const getUserDatail = () => { |
| | | getUserInfo().then(res => { |
| | | if(res.code == 200){ |
| | | userInfo.value = res.data |
| | | uni.setStorageSync('userInfo',JSON.stringify(res.data)) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | onMounted(() => { |
| | | getTopHeight() |
| | | getUserDatail() |
| | | // 获取位置信息 |
| | | getUserLocation() |
| | | }) |
| | | </script> |
| | |
| | | background-size: 100% 100%; |
| | | margin-top: 40rpx; |
| | | color: #fff; |
| | | font-size: 60rpx; |
| | | font-size: 40rpx; |
| | | padding: 0 30rpx; |
| | | box-sizing: border-box; |
| | | position: relative; |
| | | .water{ |
| | | width: 100%; |
| | | padding: 20rpx 0; |
| | | word-break: break-all; |
| | | display: -webkit-box; |
| | | -webkit-box-orient: vertical; |
| | | -webkit-line-clamp: 2; |
| | | .item{ |
| | | padding: 15rpx 0; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | } |
| | | .water .by{ |
| | | width: 100%; |
| | | } |
| | | .all{ |
| | | width: 68%; |
| | | } |
| | | .btn{ |
| | | position: absolute; |
| | | right: 30rpx; |
| | | bottom: 50rpx; |
| | | bottom: 30rpx; |
| | | button{ |
| | | width: 200rpx; |
| | | height: 80rpx; |
| | |
| | | } |
| | | .domain{ |
| | | margin-top: 40rpx; |
| | | .t{ |
| | | padding: 0 20rpx; |
| | | } |
| | | .c{ |
| | | margin-top: 20rpx; |
| | | height: 180rpx; |
| | | background: #FFFFFF; |
| | | box-shadow: 0 0 12rpx 0 rgba(13,118,255,0.0608); |
| | | border: 2rpx solid #D6ECFF; |
| | | border-radius: 20rpx; |
| | | padding: 20rpx 40rpx; |
| | | padding: 0 20rpx; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | .item{ |
| | | width: 30%; |
| | | text-align: center; |
| | | background: #FFFFFF; |
| | | box-shadow: 0 0 12rpx 0 rgba(13,118,255,0.0608); |
| | | border: 2rpx solid #D6ECFF; |
| | | border-radius: 20rpx; |
| | | padding: 20rpx 30rpx; |
| | | image{ |
| | | width: 100rpx; |
| | | height: 100rpx; |
| | |
| | | <template> |
| | | <view class="device"> |
| | | <view class="record"> |
| | | <Navbar title="充值记录"></Navbar> |
| | | <view class="header"> |
| | | <uni-data-select |
| | | v-model="dateType" |
| | | :localdata="dataTypeOption" |
| | | @change="changeTime" |
| | | :clear="false" |
| | | /> |
| | | </view> |
| | | <view class="chongzhi"> |
| | | <view class="item" v-for="(item, index) in list" :key="index"> |
| | | <vie class="info"> |
| | | <view>充值金额:<text class="val">{{item.rechargeAmount}}</text>元</view> |
| | | <view>充值水量:<text class="val">{{item.rechargeWater}}</text>m³</view> |
| | | </vie> |
| | | <view class="status"> |
| | | <view v-if="item.rechargeStatus === 1" style="color: #19d60b;">已充值</view> |
| | | <view v-else style="color: #818181;">未充值</view> |
| | | </view> |
| | | <view class="tm">{{item.createTimeView}}</view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, onMounted} from 'vue' |
| | | import Navbar from '../../components/navbar/navbar.vue' |
| | | import {getrechargeRecord} from '@/api/index.js' |
| | | import { onReachBottom } from '@dcloudio/uni-app'; |
| | | |
| | | const list = ref([]) |
| | | const page = ref(1) |
| | | const dateType = ref(0) |
| | | |
| | | const dataTypeOption = [ |
| | | { text: '全部', value: 0 }, |
| | | { text: '本日', value: 1 }, |
| | | { text: '本周', value: 2 }, |
| | | { text: '本月', value: 3 }, |
| | | { text: '本年', value: 4 } |
| | | ] |
| | | |
| | | const getData = () => { |
| | | const data = { |
| | | dateType: dateType.value, |
| | | limit: 10, |
| | | page: page.value |
| | | } |
| | | getrechargeRecord(data).then(res => { |
| | | if(res.code === 200) { |
| | | list.value = res.data.list |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 选择时间 |
| | | const changeTime = () => { |
| | | page.value = 1 |
| | | getData() |
| | | } |
| | | |
| | | // 触底加载数据 |
| | | onReachBottom(() => { |
| | | page.value ++ |
| | | getData() |
| | | }) |
| | | |
| | | onMounted(() => { |
| | | getData() |
| | | }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .chongzhi{ |
| | | padding: 0 20rpx; |
| | | .item{ |
| | | padding: 20rpx; |
| | | border-bottom: 1px solid #ddd; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | .info{ |
| | | width: 45%; |
| | | flex-shrink: 0; |
| | | text-align: left; |
| | | font-size: 24rpx; |
| | | .val{ |
| | | font-size: 28rpx; |
| | | } |
| | | } |
| | | .status{ |
| | | flex-grow: 1; |
| | | text-align: center; |
| | | } |
| | | .tm{ |
| | | flex-grow: 1; |
| | | text-align: right; |
| | | font-size: 24rpx; |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | |
| | | <template> |
| | | <view class="device"> |
| | | <view class="record"> |
| | | <Navbar title="取水记录"></Navbar> |
| | | <view class="header"> |
| | | <uni-data-select |
| | | v-model="dateType" |
| | | :localdata="dataTypeOption" |
| | | @change="changeTime" |
| | | :clear="false" |
| | | /> |
| | | </view> |
| | | <view class="qushui"> |
| | | <view class="item" v-for="(item, index) in list" :key="index"> |
| | | <vie class="info"> |
| | | <view>取水量:<text class="val">{{item.waterAmount}}</text>m³</view> |
| | | <view>剩余水量:<text class="val">{{item.balance}}</text>m³</view> |
| | | </vie> |
| | | <view class="tm">{{item.payTime}}</view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, onMounted} from 'vue' |
| | | import Navbar from '../../components/navbar/navbar.vue' |
| | | import {getqushuiRecord} from '@/api/index.js' |
| | | import { onReachBottom } from '@dcloudio/uni-app'; |
| | | |
| | | const list = ref([]) |
| | | const page = ref(1) |
| | | const dateType = ref(0) |
| | | |
| | | const dataTypeOption = [ |
| | | { text: '全部', value: 0 }, |
| | | { text: '本日', value: 1 }, |
| | | { text: '本周', value: 2 }, |
| | | { text: '本月', value: 3 }, |
| | | { text: '本年', value: 4 } |
| | | ] |
| | | |
| | | const getData = () => { |
| | | const data = { |
| | | dateType: dateType.value, |
| | | limit: 10, |
| | | page: page.value |
| | | } |
| | | getqushuiRecord(data).then(res => { |
| | | if(res.code === 200) { |
| | | list.value = res.data.list |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 选择时间 |
| | | const changeTime = () => { |
| | | page.value = 1 |
| | | getData() |
| | | } |
| | | |
| | | // 触底加载数据 |
| | | onReachBottom(() => { |
| | | page.value ++ |
| | | getData() |
| | | }) |
| | | |
| | | onMounted(() => { |
| | | getData() |
| | | }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .qushui{ |
| | | padding: 0 20rpx; |
| | | .item{ |
| | | padding: 20rpx; |
| | | border-bottom: 1px solid #ddd; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | .info{ |
| | | width: 50%; |
| | | flex-shrink: 0; |
| | | text-align: left; |
| | | font-size: 24rpx; |
| | | .val{ |
| | | font-size: 28rpx; |
| | | } |
| | | } |
| | | .tm{ |
| | | flex-grow: 1; |
| | | text-align: right; |
| | | font-size: 24rpx; |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | |
| | | <template> |
| | | <view class="user" :style="{paddingTop:topHeight + 'rpx'}"> |
| | | <view class="content"> |
| | | <view class="user"> |
| | | <view class="user" @click="setUser"> |
| | | <view class="userImg"> |
| | | <image src="/static/images/login/wx.png" mode="widthFix"></image> |
| | | <image :src="userInfo?.headImg" mode="widthFix"></image> |
| | | </view> |
| | | <view class="info"> |
| | | <text class="name">张三</text> |
| | | <text class="name">{{userInfo?.nickName}}</text> |
| | | </view> |
| | | </view> |
| | | <view class="typeList"> |
| | | <view class="typeItem"> |
| | | <view class="name">剩余水量</view> |
| | | <view class="val">750m³</view> |
| | | <view class="val">{{userInfo?.balance}}m³</view> |
| | | </view> |
| | | <view class="typeItem"> |
| | | <view class="name">总购水量</view> |
| | | <view class="val">{{userInfo?.sumBuyCount}}m³</view> |
| | | </view> |
| | | <view class="typeItem"> |
| | | <view class="name">累计水量</view> |
| | | <view class="val">{{userInfo?.sumUseCount}}m³</view> |
| | | </view> |
| | | </view> |
| | | <view class="loginOut"> |
| | |
| | | import { onMounted, ref } from "vue"; |
| | | |
| | | const topHeight = ref(0) |
| | | const userInfo = ref() |
| | | |
| | | // 获取状态栏高度 |
| | | const getTopHeight = () => { |
| | | if(uni.getMenuButtonBoundingClientRect){ |
| | | topHeight.value = uni.getMenuButtonBoundingClientRect().bottom * 2 |
| | | } |
| | | } |
| | | |
| | | const setUser = () => { |
| | | uni.navigateTo({ |
| | | url: '/pages/userSet/index' |
| | | }) |
| | | } |
| | | |
| | | // 退出登录 |
| | |
| | | |
| | | onMounted(() => { |
| | | getTopHeight() |
| | | userInfo.value = JSON.parse(uni.getStorageSync('userInfo')) |
| | | }) |
| | | </script> |
| | | |
对比新文件 |
| | |
| | | <template> |
| | | <view class="setting"> |
| | | <Navbar title="用户信息"></Navbar> |
| | | <view class="user"> |
| | | <view class="userImg" @click="chooseImg"> |
| | | <view class="t">用户头像</view> |
| | | <button class="cell-wrapper" open-type="chooseAvatar" @chooseavatar="chooseImg"> |
| | | <image class="head" :src="userForm.headImg" mode="widthFix"></image> |
| | | </button> |
| | | </view> |
| | | <view class="userName"> |
| | | <view class="t">用户昵称</view> |
| | | <input class="input" type="nickname" v-model="userForm.nickName" placeholder="请输入昵称" /> |
| | | </view> |
| | | <button class="btn" @click="savaUser">保存</button> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, onMounted} from 'vue' |
| | | import Navbar from '../../components/navbar/navbar.vue' |
| | | import {setUserInfo, getUserInfo} from '@/api/index.js' |
| | | |
| | | const userForm = ref({ |
| | | headImg: '', |
| | | nickName: '' |
| | | }) |
| | | |
| | | const chooseImg = (e) => { |
| | | if(e.detail.avatarUrl){ |
| | | userForm.value.headImg = e.detail.avatarUrl |
| | | } |
| | | } |
| | | |
| | | // 获取用户信息存缓存 |
| | | const getUser = () => { |
| | | getUserInfo().then(res => { |
| | | if(res.code == 200){ |
| | | uni.setStorageSync('userInfo',JSON.stringify(res.data)) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const savaUser = () => { |
| | | setUserInfo(userForm.value).then(res => { |
| | | if(res.code === 200) { |
| | | getUser() |
| | | uni.showToast({ |
| | | title:'修改成功', |
| | | icon: 'success' |
| | | }) |
| | | setTimeout(() => { |
| | | uni.navigateBack() |
| | | }, 1000) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | const userInfo = JSON.parse(uni.getStorageSync('userInfo')) |
| | | userForm.value = { |
| | | id: userInfo.id, |
| | | headImg: userInfo.headImg, |
| | | nickName: userInfo.nickName |
| | | } |
| | | }) |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .user{ |
| | | padding: 40rpx; |
| | | box-sizing: border-box; |
| | | .userImg{ |
| | | width: 100%; |
| | | padding: 10rpx 20rpx; |
| | | box-sizing: border-box; |
| | | border-radius: 20rpx; |
| | | background-color: #fff; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | .cell-wrapper{ |
| | | width: 80rpx; |
| | | height: 80rpx; |
| | | border-radius: 50%; |
| | | border: 0; |
| | | margin: 0; |
| | | background-color: #ddd; |
| | | } |
| | | .head{ |
| | | width: 80rpx; |
| | | height: 80rpx; |
| | | border-radius: 50%; |
| | | margin-left: -30rpx; |
| | | } |
| | | } |
| | | .userName{ |
| | | margin-top: 40rpx; |
| | | width: 100%; |
| | | padding: 30rpx 20rpx; |
| | | box-sizing: border-box; |
| | | border-radius: 20rpx; |
| | | background-color: #fff; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | .input{ |
| | | width: 200rpx; |
| | | text-align: right; |
| | | } |
| | | } |
| | | .btn{ |
| | | margin-top: 100rpx; |
| | | background-color: $uni-primary; |
| | | border-color: $uni-primary; |
| | | color: #fff; |
| | | } |
| | | } |
| | | </style> |
对比新文件 |
| | |
| | | <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1734678578243" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22526" width="65" height="65" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M82.697658 0m93.090909 0l605.090909 0q93.090909 0 93.090909 93.090909l0 837.818182q0 93.090909-93.090909 93.090909l-605.090909 0q-93.090909 0-93.090909-93.090909l0-837.818182q0-93.090909 93.090909-93.090909Z" fill="#3d9bfc" p-id="22527" data-spm-anchor-id="a313x.search_index.0.i1.6e3b3a81RusiQL" class="selected"></path><path d="M222.334022 46.545455h512a93.090909 93.090909 0 0 1 93.090909 93.090909v325.818181a46.545455 46.545455 0 0 1-46.545455 46.545455H175.788567a46.545455 46.545455 0 0 1-46.545454-46.545455V139.636364a93.090909 93.090909 0 0 1 93.090909-93.090909z" fill="#FFFFFF" p-id="22528"></path><path d="M681.504931 93.090909h-127.069091c-3.374545 0-6.283636-1.536-6.283636-3.653818v-15.965091c0-1.978182 2.653091-3.653818 6.283636-3.653818h127.069091c3.374545 0 6.283636 1.536 6.283636 3.653818v15.965091c-0.232727 2.094545-2.909091 3.653818-6.283636 3.653818z m-5.352727 23.272727h-116.363637c-6.283636 0-11.636364 3.723636-11.636363 8.564364v85.597091c0 4.654545 5.096727 8.564364 11.636363 8.564364h4.608S601.958749 256 608.265658 256h19.409455c6.283636 0 42.170182-36.910545 42.170182-36.910545h6.306909c6.283636 0 11.636364-3.746909 11.636363-8.564364V124.928C687.788567 120.087273 682.69184 116.363636 676.152204 116.363636zM402.232204 93.090909H275.163113C271.788567 93.090909 268.879476 91.554909 268.879476 89.437091v-15.965091C268.879476 71.493818 271.532567 69.818182 275.163113 69.818182h127.069091c3.374545 0 6.283636 1.536 6.283636 3.653818v15.965091c-0.232727 2.094545-2.909091 3.653818-6.283636 3.653818z m-5.352728 23.272727h-116.363636c-6.283636 0-11.636364 3.723636-11.636364 8.564364v85.597091c0 4.654545 5.096727 8.564364 11.636364 8.564364h4.608S322.686022 256 328.992931 256h19.409454c6.283636 0 42.170182-36.910545 42.170182-36.910545h6.306909c6.283636 0 11.636364-3.746909 11.636364-8.564364V124.928C408.51584 120.087273 403.419113 116.363636 396.879476 116.363636z" fill="#1A87FF" p-id="22529"></path><path d="M617.970385 418.909091a46.545455 46.545455 0 0 0 46.545455-46.545455c0-17.128727-15.522909-43.659636-46.545455-79.592727-31.022545 35.933091-46.545455 62.464-46.545454 79.592727a46.545455 46.545455 0 0 0 46.545454 46.545455z" fill="#1A87FF" p-id="22530"></path></svg> |
对比新文件 |
| | |
| | | <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1734588187711" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1709" width="43" height="43" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M890.4 959.6H132.9l102.6-185.7h552.3z" fill="#E5ECFF" p-id="1710"></path><path d="M787.5 599.9c42.2-56 67.2-125.7 67.2-201.3 0-185-150-335-335-335s-335 150-335 335c0 75.6 25 145.3 67.2 201.3l-0.5 0.5 4.2 4.2c16.9 21.6 36.4 41.1 58 58L501 870.8l18.7-2.1 206-206c21.6-16.9 41.1-36.4 58-58l4.2-4.2-0.4-0.6z" fill="#A4BEFF" p-id="1711"></path><path d="M763.3 599.9c42.2-56 67.2-125.7 67.2-201.3 0-185-150-335-335-335s-335 150-335 335c0 75.6 25 145.3 67.2 201.3l-0.5 0.5 4.2 4.2c16.9 21.6 36.4 41.1 58 58l206 206 206-206c21.6-16.9 41.1-36.4 58-58l4.2-4.2-0.3-0.5z" fill="#5B79FB" p-id="1712"></path><path d="M503.6 366.3m-92.8 0a92.8 92.8 0 1 0 185.6 0 92.8 92.8 0 1 0-185.6 0Z" fill="#FFFFFF" p-id="1713"></path><path d="M778.1 928.3H245.3l16.1-34.3h500.5z" fill="#FF7E71" p-id="1714"></path></svg> |