shoprz.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="content ">
  3. <view class="item-name">
  4. 工资认证
  5. </view>
  6. <view class="listBox">
  7. <view class="con_box">
  8. <view class="tip">
  9. 请上传最近3单工资证明
  10. </view>
  11. <view class="con_image" v-for="(item,ind) in updata.service_audit_imgs">
  12. <image class="img" @click="navCroper(400,400,'audit',ind)"
  13. :src="item"></image>
  14. <image @click="updata.service_audit_imgs.splice(ind,1)" class="tip" src="../../../static/icon/goodsExit.png" mode="scaleToFill"></image>
  15. </view>
  16. <view class="con_image">
  17. <image class="img" @click="navCroper(400,400,'auditall')"
  18. src="../../../static/image/upImg.png"></image>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="base-buttom" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">提交</view>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. subTypeAudit
  28. } from '@/api/model.js';
  29. import {
  30. mapState
  31. } from "vuex"
  32. export default {
  33. data() {
  34. return {
  35. // 上传数据
  36. updata:{
  37. service_audit_imgs: [], //服务图片
  38. },
  39. loding: false, //是否载入中
  40. };
  41. },
  42. onLoad(options) {
  43. this.init()
  44. },
  45. computed: {
  46. // #ifdef H5
  47. ...mapState(['urlFile']),
  48. // #endif
  49. ...mapState(['baseURL']),
  50. },
  51. methods: {
  52. // 初始化
  53. init() {
  54. const that = this;
  55. },
  56. upLoad(path) {
  57. // #ifdef H5
  58. console.log(path, 'h5');
  59. // #endif
  60. uni.showLoading({
  61. title: '图片上传中',
  62. mask: true
  63. });
  64. return new Promise((resolve, error) => {
  65. uni.uploadFile({
  66. url: this.baseURL + '/api/user/qiniuUpload', //仅为示例,非真实的接口地址
  67. filePath: path,
  68. name: 'file',
  69. header: {
  70. "token": uni.getStorageSync('token')
  71. },
  72. success: (uploadFileRes) => {
  73. if ("string" === typeof uploadFileRes.data) {
  74. resolve(JSON.parse(uploadFileRes.data).data)
  75. } else {
  76. resolve(uploadFileRes.data.data)
  77. }
  78. },
  79. complete() {
  80. uni.hideLoading()
  81. }
  82. });
  83. })
  84. },
  85. // 图片裁切
  86. /**
  87. * @param {Number} w 裁切宽度比例
  88. * @param {Number} h 裁切高度比例
  89. * @param {Number} mw 图片最小宽度
  90. * @param {Number} mh 图片最小高度
  91. * @param {String} url url修改
  92. */
  93. navCroper(w, h, type, ind) {
  94. let that = this;
  95. let tt = (type == 'upimg' ? 2 : 1)
  96. this.onImg(tt).then((url) => {
  97. uni.navigateTo({
  98. url: `../realName/cropper?width=${w}&height=${h}`,
  99. events: {
  100. uploadSuccess(res) {
  101. that.upLoad(res).then((urldata) => {
  102. if (type == 'audit') {
  103. that.updata.service_audit_imgs.splice(ind, 1, urldata.img)
  104. }else if (type == 'auditall') {
  105. that.updata.service_audit_imgs.push( urldata.img)
  106. }
  107. })
  108. }
  109. },
  110. success: function(res) {
  111. // 通过eventChannel向被打开页面传送数据
  112. res.eventChannel.emit('urlNext', {
  113. url
  114. })
  115. }
  116. })
  117. })
  118. },
  119. onImg(type) {
  120. const _this = this
  121. return new Promise((ok, erro) => {
  122. // 判断是否需要选择
  123. if (type == 1) {
  124. uni.showActionSheet({
  125. itemList: ['拍照', '选择一张照片'],
  126. success: function(res) {
  127. _this.chooseImage(res.tapIndex).then((url) => {
  128. ok(url)
  129. }).catch((res) => {
  130. erro(res)
  131. })
  132. },
  133. fail: function(res) {
  134. erro(res)
  135. console.log(res.errMsg);
  136. }
  137. });
  138. }
  139. // 判断是否只需要拍照
  140. if (type == 2) {
  141. _this.chooseImage(0).then((url) => {
  142. ok(url)
  143. }).catch((res) => {
  144. erro(res)
  145. })
  146. }
  147. })
  148. },
  149. chooseImage: function(index) {
  150. const _this = this
  151. return new Promise((ok, error) => {
  152. // 从相册/相机选择
  153. // 如需直接开相机或直接选相册,请只使用一个选项
  154. const sourceType = index === 0 ? ['camera'] : ['album']
  155. uni.chooseImage({
  156. count: 1, //默认9
  157. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  158. sourceType: sourceType,
  159. success: function(res) {
  160. ok(res.tempFilePaths[0])
  161. },
  162. fail(e) {
  163. uni.showModal({
  164. title: '文件打开错误',
  165. content: '请设置授权文件存储权限',
  166. showCancel: false,
  167. });
  168. error(e)
  169. }
  170. });
  171. })
  172. },
  173. // 实名认证
  174. confirm(e) {
  175. const that = this;
  176. if (that.updata.service_audit_imgs.length==0) {
  177. uni.showModal({
  178. title: '错误',
  179. content: '请上传工资截图',
  180. showCancel: false,
  181. });
  182. return
  183. }
  184. that.loding = true;
  185. subTypeAudit({
  186. service_audit_imgs:that.updata.service_audit_imgs
  187. })
  188. .then((e) => {
  189. that.loding = false;
  190. this.$api.msg(e.msg);
  191. })
  192. .catch(err => {
  193. this.loding = false;
  194. console.log(err);
  195. });
  196. }
  197. }
  198. };
  199. </script>
  200. <style lang="scss">
  201. .content,
  202. page {
  203. min-height: 100%;
  204. }
  205. .content {
  206. padding-bottom: 150rpx;
  207. }
  208. .item-name {
  209. margin: $page-row-spacing;
  210. font-size: $font-lg;
  211. font-weight: bold;
  212. color: $font-color-dark;
  213. }
  214. .con_box {
  215. margin: $page-row-spacing;
  216. .tip{
  217. color: #999999;
  218. font-size: $font-base;
  219. margin-bottom: 20rpx;
  220. }
  221. .con_image {
  222. width: 150rpx;
  223. height: 150rpx;
  224. display: inline-block;
  225. margin-right: 20rpx;
  226. position: relative;
  227. .img {
  228. width: 100%;
  229. height: 100%;
  230. }
  231. .tip {
  232. position: absolute;
  233. top: -10rpx;
  234. right: -10rpx;
  235. width: 30rpx;
  236. height: 30rpx;
  237. background-color: #FFF;
  238. border-radius: 99rpx;
  239. }
  240. }
  241. }
  242. .listBox {
  243. margin: $page-row-spacing;
  244. margin-top: 30rpx;
  245. border-radius: 20rpx;
  246. overflow: hidden;
  247. background-color: #FFFFFF;
  248. }
  249. .list {
  250. .input {
  251. text-align: right;
  252. font-size: $font-base;
  253. color: $color-gray;
  254. width: 100%;
  255. }
  256. .listItem {
  257. padding: 35rpx 40rpx;
  258. border-bottom: 1px solid $page-color-light;
  259. }
  260. .listIconImg {
  261. width: 36rpx;
  262. }
  263. .right {
  264. color: $font-color-light;
  265. font-size: $font-base;
  266. flex-grow: 1;
  267. justify-content: flex-end;
  268. .timetype {
  269. width: 100%;
  270. justify-content: flex-end;
  271. }
  272. .citylist {
  273. .del {
  274. color: $color-red;
  275. font-size: $font-sm;
  276. border: 1px solid $color-red;
  277. border-radius: 10rpx;
  278. line-height: 1;
  279. padding: 5rpx 15rpx;
  280. }
  281. }
  282. .img {
  283. width: 26rpx;
  284. }
  285. .buttom {
  286. color: $base-color;
  287. border: 1px solid $base-color;
  288. border-radius: 10rpx;
  289. line-height: 1;
  290. padding: 10rpx 20rpx;
  291. }
  292. }
  293. .titleBox {
  294. .title {
  295. color: $font-color-base;
  296. font-size: $font-base;
  297. }
  298. }
  299. }
  300. .bg-gray {
  301. background-color: $color-gray;
  302. }
  303. .base-buttom {
  304. position: fixed;
  305. bottom: 30rpx;
  306. right: 0rpx;
  307. left: 0rpx;
  308. }
  309. </style>