Shimingrenzheng.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="$t('user.shimingwsmrz')" tinColor="#006AFF" jiantou="0" titledetl=''></customNav>
  4. <view class="contentColumn contenV">
  5. <view class="">
  6. <text>{{$t('user.zhegnjiants')}}</text>
  7. </view>
  8. <view class="item_list">
  9. <view class="item_content" v-for="(item,index) in annexList">
  10. <myImage class="imageV" :defaultImage="item" :mysrc="item" mymode="widthFix" v-on:Emyimageclick="imageEvent(index)"></myImage>
  11. </view>
  12. <view class="item_content">
  13. <image class="imageV" src="/static/imags/shangctp.png" mode="widthFix" @click="addimage"></image>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="bottomfloatV">
  18. <view class="querenBt" @click="tijiaoAC">
  19. <label>{{$t('tixian.shenqingshenhe')}}</label>
  20. </view>
  21. </view>
  22. <!-- 提示窗示例 -->
  23. <uni-popup ref="alertDialog" type="dialog">
  24. <uni-popup-dialog type="NOMLE" :cancelText="$t('index.quxiao')" :confirmText="$t('index.queren')" :title="$t('user.sanchutp')" :content="sanchumsg" @confirm="dialogConfirm"
  25. @close="dialogClose"></uni-popup-dialog>
  26. </uni-popup>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. getUserMsg,
  32. updataUserMsg
  33. } from '@/pages/api/login';
  34. import {
  35. UploadImage
  36. } from '@/pages/api/basic.js';
  37. export default {
  38. data() {
  39. return {
  40. annexList:[],
  41. scale:1,
  42. sanchumsg:'',
  43. delIndex:-1,
  44. auditStatus:0
  45. }
  46. },
  47. onShow() {
  48. var userInfo = uni.getStorageSync('userInfo');
  49. this.auditStatus = userInfo.auditStatus;
  50. var annex=[];
  51. console.log(userInfo.annex)
  52. if(''==userInfo.annex||undefined==userInfo.annex||null==userInfo.annex){
  53. }
  54. else{
  55. annex=userInfo.annex.split(",");
  56. }
  57. this.annexList=annex;
  58. },
  59. methods: {
  60. tijiaoAC(){
  61. if(this.annexList.length<2){
  62. uni.showToast({
  63. title:this.$t('user.zhegnjiants'),
  64. icon:"none"
  65. })
  66. return;
  67. }
  68. if(this.auditStatus==0){
  69. uni.setStorageSync('auditStatus',9);
  70. uni.navigateBack();
  71. }
  72. },
  73. addimage(){
  74. this.selectImage();
  75. },
  76. imageEvent(index){
  77. console.log('删除图片');
  78. this.delIndex=index;
  79. var x=index+1;
  80. let str1 = this.$t('user.querenscdzt');
  81. let str2 = str1.replace('x',x);
  82. this.sanchumsg=str2;
  83. this.$refs.alertDialog.open('center');
  84. },
  85. dialogConfirm() {
  86. console.log('点击确认')
  87. if(this.delIndex<0||this.delIndex>=this.annexList.length){
  88. return;
  89. }
  90. var tempList = this.annexList;
  91. tempList.splice(this.delIndex,1);
  92. this.annexList=tempList;
  93. var images = this.annexList+'';
  94. console.log(images);
  95. var annex = {'annex':images}
  96. this.updataUserMsg(annex);
  97. },
  98. dialogClose() {
  99. console.log('点击关闭')
  100. },
  101. selectImage(){
  102. var that = this;
  103. uni.chooseImage({
  104. count: 1, // 图片数量
  105. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  106. sourceType: ['album'], //从相册选择或者拍照
  107. success: (res) => {
  108. const tempFilePaths = res.tempFilePaths;
  109. uni.uploadFile({
  110. url: this.$baseurl+UploadImage, //上传图片api
  111. filePath: tempFilePaths[0],
  112. name: 'file',
  113. header:{
  114. //"Authorization": userinfo.token
  115. },
  116. success: (res) => {
  117. let group = JSON.parse(res.data);
  118. console.log('11',that.annexList)
  119. if(that.annexList==null){
  120. that.annexList=[];
  121. }
  122. var temp = that.annexList;
  123. temp.push(group.data);
  124. that.annexList=temp;
  125. var images = that.annexList+'';
  126. console.log(images);
  127. var annex = {'annex':images}
  128. that.updataUserMsg(annex);
  129. uni.showToast({
  130. title:that.$t('user.tupiansccg'),
  131. icon:"success"
  132. })
  133. }
  134. });
  135. }
  136. });
  137. },
  138. async updataUserMsg(data){
  139. var that = this;
  140. await this.$http.post(`${updataUserMsg}`,data,true)
  141. .then(async r => {
  142. console.log('updataUserMsg',r)
  143. // uni.showToast({
  144. // title:that.$t('user.shenqingshcg'),
  145. // icon:"success"
  146. // })
  147. uni.setStorageSync('auditStatus',0);
  148. that.getUserMsg();
  149. })
  150. .catch(err => {
  151. console.log(err)
  152. })
  153. },
  154. async getUserMsg(){
  155. //console.log('getUserMsg')
  156. await this.$http.get(`${getUserMsg}`, {
  157. },true)
  158. .then(async r => {
  159. console.log(r.data)
  160. uni.setStorageSync('userInfo',r.data.data);
  161. })
  162. .catch(err => {
  163. console.log(err)
  164. })
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss">
  170. @import '@/common/common.scss';
  171. page{
  172. background-color: white;
  173. }
  174. .contenV{
  175. width: 94%;
  176. margin-left: 3%;
  177. margin-top: 30rpx;
  178. }
  179. .item_list{
  180. display: flex;
  181. flex-wrap: wrap;
  182. justify-content: space-between;
  183. }
  184. .item_content{
  185. width: 44%;
  186. margin: 20rpx;
  187. box-sizing: border-box;
  188. border: solid lightgray;
  189. }
  190. .imageV{
  191. width: 100%;
  192. }
  193. .querenBt{
  194. width: 80%;
  195. margin-left: 10%;
  196. height: 70rpx;
  197. line-height: 70rpx;
  198. border-radius: 20rpx;
  199. text-align: center;
  200. justify-content: center;
  201. background-color: #006AFF;
  202. color: white;
  203. box-shadow: 0px 0rpx 10rpx 0rpx #006AFF;
  204. }
  205. .bottomfloatV{
  206. position: fixed;
  207. flex-direction: row;
  208. align-items: center;
  209. left: 0;
  210. right: 0;
  211. bottom: 30rpx;
  212. z-index: 999;
  213. background-color: white;
  214. height: 80rpx;
  215. }
  216. </style>