index.vue 10 KB

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