环卫车小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.2 KiB

6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
  1. <template>
  2. <view>
  3. <view class="se-pt-200 se-flex se-flex-h-c se-flex-ff-cw">
  4. <image class="se-w-150 se-h-150" src="@/static/image/logo.png" mode=""></image>
  5. <view class="se-flex se-flex-h-c se-fs-34 se-fw-6 se-c-black se-mt-40">
  6. 环卫车小程序
  7. </view>
  8. <view class="se-mt-20 se-fs-26 se-c-black se-flex se-flex-h-c">
  9. 申请获取您的头像昵称
  10. </view>
  11. </view>
  12. <view class="se-mx-40 se-py-100">
  13. <view class="se-b-t se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
  14. <text>头像</text>
  15. <button class="se-w-100 se-h-100 se-p-0 se-m-0" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  16. <image v-if="imagUrl" class="se-w-100 se-h-100" :src="imagUrl"></image>
  17. <image v-else class="se-w-100 se-h-100" src="@/static/image/header.png" mode=""></image>
  18. </button>
  19. </view>
  20. <view class=" se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
  21. <text>昵称</text>
  22. <input type="nickname" placeholder="请输入昵称" v-model="nameUser"
  23. @blur="bindblur" class="se-h-80 se-lh-80 se-w-320 se-fs-24 se-ta-r" placeholder-class="se-fs-24 se-ta-r" />
  24. </view>
  25. <view class=" se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
  26. <text>手机号</text>
  27. <button v-if="phone" class="default-btn se-h-100 se-p-0 se-m-0" open-type="getPhoneNumber" @getphonenumber="onPhonenumber">{{phone}}</button>
  28. <button v-else class="se-w-140 se-h-60 se-lh-60 se-fs-20 se-bgc-green se-c-white se-py-0 se-br-30 se-px-20 se-m-0" open-type="getPhoneNumber" @getphonenumber="onPhonenumber">
  29. 获取手机号
  30. </button>
  31. </view>
  32. </view>
  33. <view class="se-mx-40">
  34. <view @click="onUpdateInfo" class="se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-white se-bgc-green">
  35. 确认
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { bindPhone,updateUser } from "@/common/api.js"
  42. export default {
  43. name : 'Login',
  44. data() {
  45. return {
  46. nameUser:"",
  47. imagUrl:"",
  48. phone:"",
  49. back:0,
  50. companyAuthenticationStatus:"",
  51. personAuthenticationStatus:"",
  52. }
  53. },
  54. onLoad(options) {
  55. this.companyAuthenticationStatus=uni.getStorageSync("companyAuthenticationStatus")
  56. this.personAuthenticationStatus=uni.getStorageSync("personAuthenticationStatus")
  57. this.imagUrl = uni.getStorageSync('userInfo').headImage
  58. this.nameUser = uni.getStorageSync('userInfo').nickName
  59. this.phone = uni.getStorageSync('userInfo').phone
  60. if(options.back==1){
  61. this.back = options.back
  62. }
  63. },
  64. methods: {
  65. bindblur(event) {
  66. this.nameUser = event.target.value
  67. },
  68. onChooseAvatar(res) {
  69. let self = this
  70. self.$Oss.ossUpload(res.target.avatarUrl).then(url => {
  71. self.imagUrl = url
  72. })
  73. },
  74. onPhonenumber(event){
  75. let that = this
  76. var detail = event.detail;
  77. if(detail.errMsg=='getPhoneNumber:ok'){
  78. let params={
  79. phoneCode : detail.code,
  80. encryptedData: detail.encryptedData,
  81. iv:detail.iv,
  82. sessionKey: uni.getStorageSync('sessionKey'),
  83. openid:uni.getStorageSync('userInfo').appletOpenid
  84. }
  85. bindPhone(params).then((response) => {
  86. console.info(response)
  87. let obj = JSON.parse(response.result)
  88. that.phone = obj.phone_info.phoneNumber
  89. }).catch(error=>{
  90. })
  91. }
  92. },
  93. onUpdateInfo(){
  94. let that = this
  95. let params={
  96. headImage:that.imagUrl,
  97. nickName:that.nameUser,
  98. phone:that.phone
  99. }
  100. if(that.imagUrl&&that.nameUser&&that.phone){
  101. updateUser(params).then((response) => {
  102. if(this.back==1){
  103. uni.navigateBack({
  104. delta:1
  105. })
  106. }else{
  107. if(that.companyAuthenticationStatus==-1 && that.personAuthenticationStatus==-1){
  108. uni.navigateTo({
  109. url:"/pages/identity/index"
  110. })
  111. }else{
  112. uni.switchTab({
  113. url:"/pages/home/index"
  114. })
  115. }
  116. // uni.switchTab({
  117. // url:"/pages/home/index"
  118. // })
  119. }
  120. }).catch((error) =>{
  121. })
  122. }else{
  123. return uni.showToast({
  124. icon:"none",
  125. title:"头像和昵称手机号,不能为空!"
  126. })
  127. }
  128. }
  129. }
  130. }
  131. </script>
  132. <style scoped lang="scss">
  133. .default-btn{
  134. background-color: #fff;
  135. }
  136. .default-btn::after{
  137. content: "";
  138. border: none;
  139. }
  140. </style>