index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <view class="body">
  3. <view class="userinfo">
  4. <view class="heardImage">
  5. <view class="img">
  6. <view style="width: 20vw; border-radius: 50%; padding: 0;margin: 0vw; height:20vw;"
  7. @click="getShow">
  8. <image class="avatar" style="width: 20vw; height: 20vw; border-radius: 50%;"
  9. :src="avatarUrl==''? '../../static/heard.png' : avatarUrl ">
  10. </image>
  11. </view>
  12. </view>
  13. <view class="usercon">
  14. <p style="display: flex;"> <span>会员:</span> <span>{{name}}</span> </p>
  15. </view>
  16. </view>
  17. <view class="bcar_border">
  18. <view class="contentBiref">
  19. <view style="display: flex; width: 96vw; justify-content: space-around; margin-top: 2vw; ">
  20. <view class="model" @click="bindLog">
  21. <p>
  22. <image style="width: 13vw; height: 13vw; " src="../../static/bindCar.png" mode=""></image>
  23. </p>
  24. <p>绑定记录</p>
  25. </view>
  26. <view class="model" @click="zhihuanCar">
  27. <p>
  28. <image style="width: 13vw; height: 13vw; " src="../../static/orderlist.png" mode=""></image>
  29. </p>
  30. <p>我的订单</p>
  31. </view>
  32. </view>
  33. <view style="display: flex; width: 96vw; justify-content: space-around; margin-top: 10vw; ">
  34. <view class="model" @click="orderList">
  35. <p>
  36. <image style="width: 13vw; height: 13vw; " src="../../static/userOrder.png" mode=""></image>
  37. </p>
  38. <p>我的询价</p>
  39. </view>
  40. <view class="model" @click="textDrive">
  41. <p>
  42. <image style="width: 13vw; height: 13vw; " src="../../static/userYuyue.png" mode=""></image>
  43. </p>
  44. <p>试驾记录</p>
  45. </view>
  46. <view class="model" @click="maintenance">
  47. <p>
  48. <image style="width: 13vw; height: 13vw; " src="../../static/userBaoyang.png" mode=""></image>
  49. </p>
  50. <p>预约记录</p>
  51. </view>
  52. </view>
  53. <view style="display: flex; width: 96vw; justify-content: space-around; margin-top: 10vw; ">
  54. <view class="model" @click="baodan">
  55. <p>
  56. <image style="width: 13vw; height: 13vw; " src="../../static/baoxian.png" mode=""></image>
  57. </p>
  58. <p>保险咨询</p>
  59. </view>
  60. <view class="model" @click="replacement">
  61. <p>
  62. <image style="width: 13vw; height: 13vw; " src="../../static/zhihuanjilu.png" mode=""></image>
  63. </p>
  64. <p>置换记录</p>
  65. </view>
  66. <view class="model" @click="CarBind">
  67. <p>
  68. <image style="width: 13vw; height: 13vw; " src="../../static/userCar.png" mode=""></image>
  69. </p>
  70. <p>车辆绑定</p>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="biref">
  76. <u-popup v-model="show" mode="bottom" border-radius="20" width="500rpx" height="300px">
  77. <view style="padding: 2vw;">
  78. <view style="display: flex; margin-top: 3vw;">
  79. <p>
  80. <image style="width: 6vw;height: 6vw;" src="/static/selectIndex.png"></image>
  81. </p>
  82. <p><span style="font-size:0.8rem;margin-left: 2vw; ">泡泡猪24小时自助洗车 </span> <span
  83. style="font-size: 0.8rem; margin-left: 2vw;">申请</span> </p>
  84. </view>
  85. <view style="font-size: 1rem; margin-top: 3vw;"> 获取你的头像、昵称 </view>
  86. <view
  87. style="display: flex; height: 15vw; margin-top: 3vw; align-items: center; justify-content:space-between; border-top: 0.5rpx solid #eaeaea; border-bottom: 0.5rpx solid #eaeaea;">
  88. <!-- <view style="display: flex; width: 26vw; justify-content: space-between; align-items: center;">
  89. </view> -->
  90. <p>头像</p>
  91. <button class="button"
  92. style="width: 80vw; margin-left: 5vw; border-radius: 10px; background-color: white; border: none; padding: 0;margin: 0vw; height: 10vw;"
  93. open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  94. <image class="avatar" style="width: 10vw; height: 10vw; border-radius: 10px;margin-left: -62vw;"
  95. :src="avatarUrl">
  96. </image>
  97. </button>
  98. <p>
  99. <image style="width: 5vw; height: 5vw; " src="../../static/danjian.png"></image>
  100. </p>
  101. </view>
  102. <view style="display: flex; height: 15vw; align-items: center; border-bottom: 0.5rpx solid #eaeaea;">
  103. <p>昵称:</p>
  104. <p style="margin-left: 5vw;"><input type="nickname" placeholder="请输入昵称" class="input" :value="name"
  105. @focus="bindblur" /></p>
  106. </view>
  107. <view
  108. style="display: flex; height: 24vw; align-items: center; justify-content: space-between; padding: 0 13vw;">
  109. <p style="width: 20vw; border-radius: 5px; background-color: #eaeaea; height: 10vw; line-height: 10vw; text-align: center; font-size: 0.75rem;"
  110. @click="operate('refuse')">拒绝</p>
  111. <p style="width: 20vw; border-radius: 5px; background-color: #0cb70c; height: 10vw; line-height: 10vw; text-align: center; font-size: 0.75rem;"
  112. @click="operate('allow')">允许</p>
  113. </view>
  114. </view>
  115. </u-popup>
  116. </view>
  117. </view>
  118. <!-- <view style=" width: 100vw; height: 50vw; text-align: center; line-height: 50vw; ">暂无内容</view> -->
  119. </view>
  120. </template>
  121. <script>
  122. import { vShow } from "vue"
  123. export default {
  124. data() {
  125. return {
  126. show:false,
  127. avatarUrl: '',
  128. avatar:'',
  129. name:''
  130. }
  131. },
  132. onLoad() {
  133. },
  134. onShow() {
  135. if(!this.$db.get('token')){
  136. uni.navigateTo({
  137. url:'/pages/login/login'
  138. })
  139. }
  140. this.getUser()
  141. },
  142. onTabItemTap(e){
  143. },
  144. methods: {
  145. bindLog(){
  146. uni.navigateTo({
  147. url:'/pages/userInfo/bindlog'
  148. })
  149. },
  150. baodan(){
  151. uni.navigateTo({
  152. url:'/pages/userInfo/baoxian'
  153. })
  154. },
  155. zhihuanCar(){
  156. uni.navigateTo({
  157. url:'/pages/userInfo/Vehicle'
  158. })
  159. },
  160. maintenance(){
  161. uni.navigateTo({
  162. url:'/pages/userInfo/maintenance'
  163. })
  164. },
  165. textDrive(){
  166. uni.navigateTo({
  167. url:'/pages/userInfo/TestDrive'
  168. })
  169. },
  170. orderList(){
  171. uni.navigateTo({
  172. url:'/pages/userInfo/orderList'
  173. })
  174. },
  175. replacement(){
  176. uni.navigateTo({
  177. url:'/pages/userInfo/replacementlog'
  178. })
  179. },
  180. // 获取个人信息
  181. getUser(){
  182. this.$api.getUserInfo(res=>{
  183. if(res.code==0){
  184. this.getBase64ImageUrl(res.data.face)
  185. this.avatar=res.data.face
  186. this.name=res.data.name
  187. if(res.data.face==''){
  188. this.show=true
  189. }
  190. }
  191. })
  192. },
  193. getShow(){
  194. this.show=true
  195. },
  196. onChooseAvatar(e) {
  197. this.base64(e.detail.avatarUrl)
  198. this.avatarUrl = e.detail.avatarUrl // 此处是头像的临时路径
  199. },
  200. bindblur(e) {
  201. this.name = e.detail.value // 获取微信昵称
  202. },
  203. // 操作是否上传头像
  204. operate(item) {
  205. this.$store.commit('getNicknameState', 1)
  206. if (item == 'allow') {
  207. // 调接口传数据
  208. // if(this.avatar==''){
  209. // this.avatar=this.avatarUrl
  210. // }
  211. this.$api.postupUserInfo({
  212. face: this.avatar,
  213. name: this.name
  214. }, res => {
  215. if (res.code == 0) {
  216. this.show = false
  217. }
  218. })
  219. } else {
  220. this.show = false
  221. }
  222. },
  223. //// 图片转64代码
  224. async base64(url, type) {
  225. await wx.getFileSystemManager().readFile({
  226. filePath: url, //选择图片返回的相对路径
  227. encoding: 'base64', //编码格式
  228. success: res => {
  229. this.avatar=res.data
  230. },
  231. fail: res => this.errorToast(res.msg)
  232. })
  233. },
  234. //把base64转换成图片
  235. getBase64ImageUrl(base64Url) {
  236. var base64Data = base64Url;
  237. /// 通过微信小程序自带方法将base64转为二进制去除特殊符号,再转回base64
  238. base64Data = uni.arrayBufferToBase64(uni.base64ToArrayBuffer(base64Data));
  239. /// 拼接请求头,data格式可以为image/png或者image/jpeg等,看需求
  240. this.avatarUrl = "data:image/png;base64," + base64Data;
  241. },
  242. // 车辆绑定
  243. CarBind(){
  244. uni.navigateTo({
  245. url:'/pages/userInfo/bindCar'
  246. })
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .button::after {
  253. border: none;
  254. }
  255. .body {
  256. width: 100vw;
  257. height: 100vh;
  258. background-color: white;
  259. .userinfo {
  260. width: 100vw;
  261. height: 100vh;
  262. background-color: white;
  263. overflow: hidden;
  264. // .bcar_border{
  265. // width: 100vw;
  266. // height: 10vh;
  267. // background-color: #f1f1f1;
  268. // .model{
  269. // width: 28vw;
  270. // height: 20vw;
  271. // display: flex;
  272. // justify-content: center;
  273. // align-items: center;
  274. // flex-direction: column;
  275. // }
  276. // }
  277. .heardImage {
  278. display: flex;
  279. align-items: center;
  280. height: 15vh;
  281. margin-top: 2vw;
  282. margin-left: 10vw;
  283. margin-bottom: 2vw;
  284. .img {
  285. width: 20vw;
  286. height: 20vw;
  287. background-color: white;
  288. border-radius: 50%;
  289. }
  290. .usercon {
  291. font-size: 1rem;
  292. margin-left: 4vw;
  293. }
  294. }
  295. .biref {
  296. width: 100vw;
  297. height: 50vw;
  298. .contentBiref {
  299. width: 96vw;
  300. margin-left: 2vw;
  301. z-index: 999;
  302. background-color: white;
  303. height: 40vw;
  304. border-radius: 5px;
  305. display: flex;
  306. flex-wrap: wrap;
  307. justify-content: space-around;
  308. .model{
  309. width: 28vw;
  310. height: 20vw;
  311. display: flex;
  312. justify-content: center;
  313. align-items: center;
  314. flex-direction: column;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. </style>