index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view class="user-info-wrap">
  3. <view class="nav-bar">
  4. <view class="nav-content">
  5. <view class="nav-info">
  6. <view class="nav-desc">
  7. <view class="nav-name">
  8. <view class="">头像</view>
  9. </view>
  10. </view>
  11. <view @click="uploadImg1(1)" class="arrow-right">
  12. <view class="head-img">
  13. <image :src="userInfo.facePhotoUrl || '/static/me/u4.png'" mode=""></image>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="custom-line"></view>
  19. <view class="cotent-from">
  20. <u--form
  21. labelPosition="left"
  22. :model="userInfo"
  23. :rules="rules"
  24. ref="form1"
  25. >
  26. <u-form-item
  27. label="昵称"
  28. prop="nickName"
  29. labelWidth="auto"
  30. labelAlign="right"
  31. >
  32. <u--input
  33. v-model="userInfo.nickName"
  34. placeholder="请输入昵称"
  35. border="bottom"
  36. maxlength="20"
  37. type="text"
  38. ></u--input>
  39. </u-form-item>
  40. <u-form-item
  41. labelWidth="auto"
  42. labelAlign="right"
  43. label="关系"
  44. prop="blood"
  45. width="120"
  46. >
  47. <u--input
  48. maxlength="20"
  49. v-model="userInfo.blood"
  50. placeholder="请输入关系"
  51. border="bottom"
  52. type="text"
  53. ></u--input>
  54. </u-form-item>
  55. <u-form-item
  56. labelWidth="auto"
  57. labelAlign="right"
  58. label="备注"
  59. prop="remark"
  60. width="120"
  61. >
  62. <u--input
  63. maxlength="20"
  64. v-model="userInfo.remark"
  65. placeholder="请输入备注"
  66. border="bottom"
  67. type="text"
  68. ></u--input>
  69. </u-form-item>
  70. </u--form>
  71. </view>
  72. </view>
  73. <view @click="saveUserInfo()" class="sure-btn">
  74. <view class="btn">确认</view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. export default {
  80. data() {
  81. return {
  82. userInfo: {
  83. auth: true,
  84. nickName: '',
  85. facePhoto: '',
  86. blood: '',
  87. remark: '',
  88. id: ''
  89. },
  90. genderShow: false,
  91. value1: '2023-12-12',
  92. imgUrl1: '',
  93. rules:[]
  94. };
  95. },
  96. mounted() {
  97. },
  98. onShow(){
  99. if (this.userInfo.facePhoto){
  100. this.getImgUrlByOssId(this.userInfo.facePhoto)
  101. }
  102. },
  103. onLoad(option) {
  104. console.log('++++++++++++++++option+++++++++++++++',option)
  105. if(option.data){
  106. this.userInfo = JSON.parse(option.data);
  107. if (this.userInfo.facePhoto){
  108. this.getImgUrlByOssId(this.userInfo.facePhoto)
  109. }
  110. }
  111. },
  112. methods: {
  113. getImgUrlByOssId(Id){
  114. if (Id) {
  115. this.$api.getImage(Id).then(res=>{
  116. this.userInfo.facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  117. this.$set(this.userInfo)
  118. });
  119. }
  120. },
  121. // 保存用户信息
  122. saveUserInfo(){
  123. if(!this.userInfo.nickName){
  124. uni.showToast({
  125. title: "请填写昵称"
  126. })
  127. return;
  128. }
  129. if(!this.userInfo.blood){
  130. uni.showToast({
  131. title: "请填写关系"
  132. })
  133. return;
  134. }
  135. if(!this.userInfo.remark){
  136. uni.showToast({
  137. title: "请填写备注"
  138. })
  139. return;
  140. }
  141. this.userInfo.auth = true;
  142. if(this.userInfo.opType == '1'){ // 绑定
  143. // 保存数据
  144. this.$api.bindServiceObject(this.userInfo).then((res)=>{
  145. // 去服务对象列表页
  146. uni.navigateTo({
  147. url: '/myPages/ServiceObjectManagement/index',
  148. })
  149. }).catch(() =>{
  150. uni.showToast({
  151. title: "操作失败"
  152. })
  153. });
  154. }else if(this.userInfo.opType == '2'){ // 修改
  155. // 修改数据
  156. this.$api.updateServiceObject(this.userInfo).then((res)=>{
  157. // 去服务对象列表页
  158. uni.navigateTo({
  159. url: '/myPages/ServiceObjectManagement/index',
  160. })
  161. }).catch(() =>{
  162. uni.showToast({
  163. title: "操作失败"
  164. })
  165. });
  166. }
  167. },
  168. //头像上传
  169. uploadImg1(imgIndex) {
  170. let that = this;
  171. uni.chooseImage({
  172. count: 1,
  173. success: (chooseImageRes) => {
  174. const tempFilePaths = chooseImageRes.tempFilePaths;
  175. uni.uploadFile({
  176. url: that.$baseUrl + '/resource/oss/upload', //仅为示例,非真实的接口地址
  177. filePath: tempFilePaths[0],
  178. name: 'file',
  179. header: {
  180. 'Authorization': 'Bearer ' + uni.getStorageInfo('accessToken'),
  181. },
  182. success: (uploadFileRes) => {
  183. let res = JSON.parse(uploadFileRes.data)
  184. that.userInfo.facePhotoUrl = res.data.url.replace(/^http:/, "https:");
  185. that.userInfo.facePhoto = res.data.ossId
  186. }
  187. });
  188. }
  189. });
  190. }
  191. }
  192. };
  193. </script>
  194. <style lang="scss">
  195. .user-info-wrap{
  196. margin-left: 12px;
  197. margin-right: 12px;
  198. /* 导航菜单 */
  199. .nav-bar{
  200. background: #fff;
  201. border-radius: 10px;
  202. margin-top: 12px;
  203. .cotent-from{
  204. padding-right: 12px;
  205. padding-left: 12px;
  206. }
  207. /* 商店信息 */
  208. .nav-content{
  209. padding-right: 6px;
  210. padding-top: 10px;
  211. padding-bottom: 6px;
  212. .nav-info{
  213. display: flex;
  214. justify-content: space-between;
  215. padding-left: 10px;
  216. align-items: center;
  217. .logo {
  218. width: 12%;
  219. text-align: center;
  220. image{
  221. width: 24px;
  222. height: 24px;
  223. }
  224. }
  225. .nav-desc{
  226. width: 46%;
  227. display: flex;
  228. line-height: 30px;
  229. font-family: PingFangSC-Regular, PingFang SC;
  230. font-weight: 400;
  231. align-items: center;
  232. .custom-input{
  233. font-size: 12px;
  234. }
  235. .nav-name{
  236. width: 60%;
  237. font-size: 14px;
  238. color: #333333;
  239. line-height: 22px;
  240. }
  241. .change-store{
  242. text-align: right;
  243. width: 40%;
  244. font-size: 12px;
  245. color: #333333;
  246. line-height: 22px;
  247. }
  248. }
  249. .arrow-right{
  250. width: 50px;
  251. height: 50px;
  252. display: flex;
  253. justify-content: flex-end;
  254. .head-img {
  255. width: 50px;
  256. height: 50px;
  257. border-radius: 25px;
  258. image{
  259. width: 50px;
  260. height: 50px;
  261. border-radius: 25px;
  262. }
  263. }
  264. .change-store{
  265. font-size: 14px;
  266. color: #999;
  267. line-height: 22px;
  268. }
  269. }
  270. }
  271. }
  272. }
  273. .sure-btn{
  274. margin-top: 20px;
  275. width: 100%;
  276. .btn{
  277. text-align: center;
  278. height: 42px;
  279. background: #FFE05C;
  280. border-radius: 27px;
  281. color: #333333;
  282. line-height: 42px;
  283. margin-top: 12px;
  284. font-size: 14px;
  285. }
  286. }
  287. }
  288. </style>