set.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="template-set">
  3. <!-- 顶部自定义导航 -->
  4. <tn-nav-bar fixed alpha customBack>
  5. <view slot="back" class='tn-custom-nav-bar__back'
  6. @click="goBack">
  7. <text class='icon tn-icon-left'></text>
  8. </view>
  9. <view slot="default">
  10. <view>
  11. <text :style="{fontSize:(wxFontSize)+'px'}">个人信息</text>
  12. </view>
  13. </view>
  14. </tn-nav-bar>
  15. <view class="tn-margin-top" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
  16. <view style="text-align: center;">
  17. <uni-file-picker
  18. v-model="value" mode="list" :auto-upload="false" @select="select" @success="success">
  19. <image v-if="!userInfo.profilePhotoUrl" src="../static/me2.png" style="width: 100px;height: 100px;"></image>
  20. <image v-if="userInfo.profilePhotoUrl" :src="userInfo.profilePhotoUrl" style="width: 100px;height: 100px;border-radius: 50%;"></image>
  21. <view><text class="tn-color-grey" :style="{fontSize:(wxFontSize-4)+'px'}">点击修改</text></view>
  22. </uni-file-picker>
  23. </view>
  24. <view class="" style="padding: 16px;
  25. margin-top: 16px;">
  26. <uni-forms :modelValue="formData" label-width="100px">
  27. <uni-forms-item label="用户昵称" name="name" :labelFontSize="wxFontSize-2">
  28. <uni-easyinput type="text" :clearable="false" v-model="userInfo.contactNickName" :inputSize="wxFontSize-3" :placeholder-style="styleString" placeholder="请输入昵称" />
  29. </uni-forms-item>
  30. <uni-forms-item label="真实姓名" name="realName" :labelFontSize="wxFontSize-2">
  31. <uni-easyinput type="text" :clearable="false" v-model="userInfo.userRealName" :inputSize="wxFontSize-3" :placeholder-style="styleString" placeholder="请输入姓名" />
  32. </uni-forms-item>
  33. <uni-forms-item label="联系方式" name="contactMethod" :labelFontSize="wxFontSize-2">
  34. <uni-easyinput type="text" v-model="userInfo.contactMethod" :clearable="false" :inputSize="wxFontSize-3" :placeholder-style="styleString" placeholder="请输入手机号码/邮箱/微信" />
  35. </uni-forms-item>
  36. <uni-forms-item label="手机号" name="phone" :labelFontSize="wxFontSize-2">
  37. <uni-easyinput type="text" disabled v-model="userInfo.userName" :inputSize="wxFontSize-3" :placeholder-style="styleString" placeholder=" " />
  38. </uni-forms-item>
  39. </uni-forms>
  40. <button shape="round" style="background-color: #1d60b1;border-radius: 30px;" type="primary" @click="saveForm">保存修改</button>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
  47. import request from '../utils/request';
  48. export default {
  49. name: 'TemplateSet',
  50. mixins: [template_page_mixin],
  51. data(){
  52. return {
  53. wxFontSize: 17,
  54. show1: false,
  55. show2: false,
  56. show3: false,
  57. index: 0,
  58. array: ['女', '男', '保密'],
  59. date: '2000-01-29',
  60. index1: 1,
  61. array1: ['计算机/电子', '广告/媒体', '会计/金融', '政府/非盈利组织/其他'],
  62. userInfo:{
  63. profilePhotoUrl:uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).profilePhotoUrl:'',
  64. contactNickName:uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).contactNickName:'',
  65. contactMethod:uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).contactMethod:'',
  66. userName:uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).userName:''
  67. },
  68. styleString:'font-size:'+14+'px'
  69. }
  70. },
  71. computed: {
  72. startDate() {
  73. return this.getDate('start');
  74. },
  75. endDate() {
  76. return this.getDate('end');
  77. }
  78. },
  79. onLoad(){
  80. const appBaseInfo = wx.getAppBaseInfo();
  81. this.wxFontSize = uni.getStorageSync('fontSize')||appBaseInfo.fontSizeSetting||17;
  82. this.styleString='font-size:'+(this.wxFontSize-3)+'px';
  83. this.getInfo();
  84. },
  85. methods: {
  86. // 跳转
  87. tn(e) {
  88. uni.navigateTo({
  89. url: e,
  90. });
  91. },
  92. // 弹出模态框
  93. showModal1(event) {
  94. this.openModal1()
  95. },
  96. // 打开模态框
  97. openModal1() {
  98. this.show1 = true
  99. },
  100. // 弹出模态框
  101. showModal2(event) {
  102. this.openModal2()
  103. },
  104. // 打开模态框
  105. openModal2() {
  106. this.show2 = true
  107. },
  108. // 弹出模态框
  109. showModal3(event) {
  110. this.openModal3()
  111. },
  112. // 打开模态框
  113. openModal3() {
  114. this.show3 = true
  115. },
  116. bindPickerChange: function(e) {
  117. this.index = e.detail.value
  118. },
  119. bindPickerChange1: function(e) {
  120. this.index1 = e.detail.value
  121. },
  122. bindDateChange: function(e) {
  123. this.date = e.detail.value
  124. },
  125. getDate(type) {
  126. const date = new Date();
  127. let year = date.getFullYear();
  128. let month = date.getMonth() + 1;
  129. let day = date.getDate();
  130. if (type === 'start') {
  131. year = year - 60;
  132. } else if (type === 'end') {
  133. year = year + 2;
  134. }
  135. month = month > 9 ? month : '0' + month;
  136. day = day > 9 ? day : '0' + day;
  137. return `${year}-${month}-${day}`;
  138. },
  139. getInfo(){
  140. request.post('/slbWxma/getPersonlInfo',{}).then(res=>{
  141. if(res&&res.success){
  142. this.userInfo = res.resultMap.userInfo||{}
  143. }
  144. })
  145. },
  146. saveForm(){
  147. const that = this;
  148. let params= this.userInfo;
  149. request.post('/slbWxma/changePersonlInfo',{userInfo:JSON.stringify(params)},{
  150. headers: {
  151. 'Content-Type': 'application/json', // 默认值
  152. },
  153. }).then(res=>{
  154. if(res.success){
  155. uni.showToast({
  156. title:'修改成功'
  157. })
  158. uni.navigateBack();
  159. }
  160. })
  161. },
  162. // 获取上传状态
  163. select(e) {
  164. console.log('选择文件:', e)
  165. let tempFiles = e.tempFiles;
  166. for (let i in tempFiles) {
  167. this.upfile(tempFiles[i])
  168. }
  169. },
  170. upfile(file) {
  171. let that = this;
  172. console.warn(file);
  173. uni.uploadFile({
  174. url: 'https://slb-m.lx-device.com/oss/upload/userFeedback', //仅为示例,非真实的接口地址
  175. filePath: file.url,
  176. name: 'file',
  177. success: (uploadFileRes) => {
  178. console.warn(JSON.parse(uploadFileRes.data));
  179. let resultMap = JSON.parse(uploadFileRes.data).resultMap;
  180. that.userInfo.profilePhotoUrl= resultMap.uploadUrl;
  181. }
  182. });
  183. },
  184. // 上传成功
  185. success(e) {
  186. console.log('上传成功')
  187. },
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. /* 胶囊*/
  193. .tn-custom-nav-bar__back {
  194. width: 60%;
  195. height: 100%;
  196. position: relative;
  197. display: flex;
  198. justify-content: space-evenly;
  199. align-items: center;
  200. box-sizing: border-box;
  201. // background-color: rgba(0, 0, 0, 0.15);
  202. border-radius: 1000rpx;
  203. border: 1rpx solid rgba(255, 255, 255, 0.5);
  204. // color: #FFFFFF;
  205. font-size: 18px;
  206. .icon {
  207. display: block;
  208. flex: 1;
  209. margin: auto;
  210. text-align: center;
  211. }
  212. }
  213. /* 间隔线 start*/
  214. .tn-strip-bottom-min {
  215. width: 100%;
  216. border-bottom: 1rpx solid #F8F9FB;
  217. }
  218. .tn-strip-bottom {
  219. width: 100%;
  220. border-bottom: 20rpx solid rgba(241, 241, 241, 0.8);
  221. }
  222. /* 间隔线 end*/
  223. /* 用户头像 start */
  224. .logo-image {
  225. width: 80rpx;
  226. height: 80rpx;
  227. position: relative;
  228. }
  229. .logo-pic {
  230. background-size: cover;
  231. background-repeat: no-repeat;
  232. // background-attachment:fixed;
  233. background-position: top;
  234. border: 2rpx solid rgba(255,255,255,0.05);
  235. box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
  236. border-radius: 50%;
  237. overflow: hidden;
  238. // background-color: #FFFFFF;
  239. }
  240. /* 底部悬浮按钮 start*/
  241. .tn-tabbar-height {
  242. min-height: 100rpx;
  243. height: calc(120rpx + env(safe-area-inset-bottom) / 2);
  244. }
  245. .tn-footerfixed {
  246. position: fixed;
  247. width: 100%;
  248. bottom: calc(30rpx + env(safe-area-inset-bottom));
  249. z-index: 1024;
  250. box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0);
  251. }
  252. /deep/ .uni-file-picker__container {
  253. justify-content: center;
  254. }
  255. /deep/ .file-picker__box-content {
  256. border: none !important;
  257. }
  258. /deep/ .uni-file-picker__lists{
  259. display: none;
  260. }
  261. /deep/ .uni-forms-item__label {
  262. font-size: 16px;
  263. }
  264. /* 底部悬浮按钮 end*/
  265. </style>