shoprz.vue 7.1 KB

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