index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="supplier" :style="colorStyle">
  3. <view class="conters">
  4. <view class="header">
  5. <image :src="picUrl"></image>
  6. <view class="record acea-row row-center-wrapper" @click="record">申请记录<text class="iconfont icon-gengduo3"></text></view>
  7. </view>
  8. <form @submit="formSubmit">
  9. <view class="list">
  10. <view class='item acea-row row-between row-bottom'>
  11. <view>供应商名称</view>
  12. <input placeholder="请输入供应商名称" placeholder-class='placeholder' name='system_name' v-model="system_name" maxlength="20"></input>
  13. </view>
  14. <view class='item acea-row row-between row-bottom'>
  15. <view>联系人</view>
  16. <input placeholder="请输入联系人姓名" placeholder-class='placeholder' name='name' v-model="name" maxlength="10"></input>
  17. </view>
  18. <view class='item acea-row row-between row-bottom'>
  19. <view>联系电话</view>
  20. <input placeholder="请输入手机号" placeholder-class='placeholder' name='phone' v-model="phone"></input>
  21. </view>
  22. <view class='item acea-row row-between row-bottom'>
  23. <view>验证码</view>
  24. <view class="itemCon acea-row row-between row-bottom">
  25. <input class="code" placeholder="请输入验证码" placeholder-class='placeholder' name='captcha' v-model="captcha"></input>
  26. <button class="bnt acea-row row-center-wrapper" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  27. {{ text }}
  28. </button>
  29. </view>
  30. </view>
  31. <view class="tip">请上传营业执照及行业相关资质证明图片</view>
  32. <view class="info">(图片最多可上传10张,图片格式支持JPG、PNG、JPEG)</view>
  33. <view class="picList acea-row row-middle">
  34. <view class='pictrue' v-for="(item,index) in pics" :key="index" v-if="index<10">
  35. <image :src='item'></image>
  36. <text class='iconfont icon-guanbi1' @click='DelPic(index)'></text>
  37. </view>
  38. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic'
  39. v-if="pics.length < 10">
  40. <text class='iconfont icon-dizhi-tianjia'></text>
  41. </view>
  42. </view>
  43. <view class="protocol">
  44. <checkbox-group @change='ChangeIsDefault'>
  45. <checkbox class="animated" :class="inAnimation?'headShake':''" @animationend='inAnimation=false'
  46. :checked="protocol ? true : false" />已阅读并同意 <text class="font-color" @click="getAgreement">《供应商协议》</text>
  47. </checkbox-group>
  48. </view>
  49. <button form-type="submit" class="confirmBnt bg-color">提交申请</button>
  50. </view>
  51. </form>
  52. </view>
  53. <agreement ref="supplier" :showAgree='showAgree' @close='close'></agreement>
  54. <canvas canvas-id="canvas" v-if="canvasStatus"
  55. :style="{width: canvasWidth + 'px', height: canvasHeight + 'px',position: 'absolute',left:'-100000px',top:'-100000px'}"></canvas>
  56. <Verify @success="success" :captchaType="'blockPuzzle'" :imgSize="{ width: '330px', height: '155px' }"
  57. ref="verify"></Verify>
  58. <!-- #ifdef MP -->
  59. <!-- <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize> -->
  60. <!-- #endif -->
  61. <home v-if="navigation"></home>
  62. </view>
  63. </template>
  64. <script>
  65. import sendVerifyCode from "@/mixins/SendVerifyCode";
  66. import colors from '@/mixins/color.js';
  67. import Verify from '../components/verify/verify.vue';
  68. import agreement from '../components/agreement/index.vue';
  69. import home from '@/components/home';
  70. import { mapGetters } from "vuex";
  71. import { toLogin } from '@/libs/login.js';
  72. import { HTTP_REQUEST_URL } from '@/config/app';
  73. import { getCodeApi, registerVerify, applySupplier, userApply } from '@/api/user.js';
  74. export default{
  75. mixins: [sendVerifyCode,colors],
  76. components: {
  77. Verify,
  78. agreement,
  79. home
  80. },
  81. computed: mapGetters(['isLogin']),
  82. data(){
  83. return{
  84. id:0,
  85. protocol: false,
  86. keyCode: '',
  87. system_name:'',
  88. name:'',
  89. phone:'',
  90. pics: [],
  91. captcha:'',
  92. canvasWidth: "",
  93. canvasHeight: "",
  94. canvasStatus: false,
  95. inAnimation: false,
  96. isShowAuth: false,//是否隐藏授权
  97. protocol: false,
  98. imgHost:HTTP_REQUEST_URL,
  99. picUrl:'',
  100. showAgree:false
  101. }
  102. },
  103. onLoad(options){
  104. this.id = options.id || 0;
  105. if(this.id>0){
  106. this.supplierApply();
  107. }
  108. this.colorData();
  109. let imgHost = this.imgHost + '/statics/images/'
  110. let picList = [
  111. imgHost+'supplierApplyGreen.jpg',
  112. imgHost+'supplierApplyRed.jpg',
  113. imgHost+'supplierApplyBule.jpg',
  114. imgHost+'supplierApplyPink.jpg',
  115. imgHost+'supplierApplyOrange.jpg',
  116. imgHost+'supplierApplyGolden.jpg'
  117. ]
  118. setTimeout(()=>{
  119. switch (this.colorNum) {
  120. case 1:
  121. this.picUrl = picList[2]
  122. break;
  123. case 2:
  124. this.picUrl = picList[0]
  125. break;
  126. case 3:
  127. this.picUrl = picList[1]
  128. break;
  129. case 4:
  130. this.picUrl = picList[3]
  131. break;
  132. case 5:
  133. this.picUrl = picList[4]
  134. break;
  135. case 6:
  136. this.picUrl = picList[5]
  137. break;
  138. default:
  139. this.picUrl = picList[2]
  140. break
  141. }
  142. },1)
  143. },
  144. onShow(){
  145. if (!this.isLogin) {
  146. toLogin();
  147. }
  148. },
  149. methods:{
  150. /**
  151. * 授权回调
  152. */
  153. onLoadFun(e) {
  154. this.isShowAuth = false;
  155. },
  156. // 授权关闭
  157. authColse(e) {
  158. this.isShowAuth = e
  159. },
  160. success(data) {
  161. this.$refs.verify.hide()
  162. getCodeApi()
  163. .then(res => {
  164. this.keyCode = res.data.key;
  165. this.getCode(data);
  166. })
  167. .catch(res => {
  168. this.$util.Tips({
  169. title: res
  170. });
  171. });
  172. },
  173. async getCode(data){
  174. let that = this;
  175. await registerVerify({
  176. phone: that.phone,
  177. type: 'supplier',
  178. key: that.keyCode,
  179. captchaType: 'blockPuzzle',
  180. captchaVerification: data.captchaVerification,
  181. })
  182. .then(res => {
  183. that.$util.Tips({
  184. title: res.msg
  185. });
  186. that.sendCode();
  187. })
  188. .catch(res => {
  189. that.$util.Tips({
  190. title: res
  191. });
  192. });
  193. },
  194. formSubmit() {
  195. if (!this.protocol) {
  196. this.inAnimation = true
  197. return this.$util.Tips({
  198. title: '请先阅读并同意协议'
  199. });
  200. }
  201. if (!this.system_name) return this.$util.Tips({
  202. title: '请输入供应商名称'
  203. });
  204. if (!this.name) return this.$util.Tips({
  205. title: '请输入联系人姓名'
  206. });
  207. if (!this.phone) return this.$util.Tips({
  208. title: '请填写手机号码'
  209. });
  210. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.phone)) return this.$util.Tips({
  211. title: '请输入正确的手机号码'
  212. });
  213. if (!this.captcha) return this.$util.Tips({
  214. title: '请输入验证码'
  215. });
  216. applySupplier(this.id,{
  217. system_name: this.system_name,
  218. name: this.name,
  219. phone: this.phone,
  220. captcha: this.captcha,
  221. images: this.pics.slice(0,10)
  222. }).then(res => {
  223. uni.reLaunch({
  224. url: '/pages/users/supplier_state/index?id='+ res.data.id
  225. })
  226. }).catch(err => {
  227. return this.$util.Tips({
  228. title: err
  229. });
  230. });
  231. },
  232. ChangeIsDefault(e) {
  233. this.$set(this, 'protocol', !this.protocol);
  234. },
  235. supplierApply(){
  236. userApply(this.id).then(res=>{
  237. let data = res.data;
  238. this.system_name = data.system_name;
  239. this.name = data.name;
  240. this.phone = data.phone;
  241. this.pics = data.images;
  242. }).catch(err=>{
  243. return this.$util.Tips({
  244. title: err
  245. });
  246. })
  247. },
  248. record(){
  249. uni.navigateTo({
  250. url: '/pages/users/record_list/index'
  251. })
  252. },
  253. /**
  254. * 删除图片
  255. *
  256. */
  257. DelPic(index) {
  258. let that = this,
  259. pic = this.pics[index];
  260. let pics = that.pics.slice(0,10);
  261. pics.splice(index, 1);
  262. that.$set(that, 'pics', pics);
  263. },
  264. /**
  265. * 上传文件
  266. *
  267. */
  268. uploadpic() {
  269. let that = this;
  270. this.canvasStatus = true
  271. that.$util.uploadImageChange({count:8,url:'upload/image'}, function(res) {
  272. that.pics.push(res.data.url);
  273. }, (res) => {
  274. this.canvasStatus = false
  275. }, (res) => {
  276. this.canvasWidth = res.w
  277. this.canvasHeight = res.h
  278. });
  279. },
  280. /**
  281. * 发送验证码
  282. *
  283. */
  284. code(data) {
  285. let that = this;
  286. if (!that.protocol) {
  287. this.inAnimation = true
  288. return that.$util.Tips({
  289. title: '请先阅读并同意协议'
  290. });
  291. }
  292. if (!that.phone) return that.$util.Tips({
  293. title: '请填写手机号码'
  294. });
  295. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone)) return that.$util.Tips({
  296. title: '请输入正确的手机号码'
  297. });
  298. this.$refs.verify.show()
  299. },
  300. getAgreement(){
  301. this.$refs.supplier.getAgreement();
  302. this.showAgree = true;
  303. },
  304. close(){
  305. this.showAgree = false;
  306. }
  307. }
  308. }
  309. </script>
  310. <style lang="scss">
  311. .supplier{
  312. height: 100vh;
  313. background-color: var(--view-theme);
  314. padding-bottom: 10rpx;
  315. .conters{
  316. background-color: var(--view-theme);
  317. padding-bottom: 10rpx;
  318. }
  319. .header{
  320. width: 750rpx;
  321. height: 400rpx;
  322. position: relative;
  323. image{
  324. width: 100%;
  325. height: 100%;
  326. }
  327. .record{
  328. position: absolute;
  329. right: 0;
  330. top:0;
  331. width: 144rpx;
  332. height: 44rpx;
  333. color: #FFDDB8;
  334. background-color: rgba(0, 0, 0, 0.3);
  335. border-radius: 22rpx 0 0 22rpx;
  336. font-size: 24rpx;
  337. padding-left: 6rpx;
  338. margin-top: 22rpx;
  339. .iconfont{
  340. font-size: 18rpx;
  341. margin-left: 6rpx;
  342. }
  343. }
  344. }
  345. .list{
  346. width: 690rpx;
  347. background-color: #fff;
  348. margin: -108rpx auto 0 auto;
  349. border-radius: 24rpx;
  350. position: relative;
  351. z-index: 1;
  352. padding: 20rpx 51rpx 72rpx 51rpx;
  353. .item{
  354. height: 104rpx;
  355. border-bottom: 1px solid #E9E9E9;
  356. padding-bottom: 22rpx;
  357. position: relative;
  358. input{
  359. width: 388rpx;
  360. font-size: 28rpx;
  361. }
  362. .placeholder{
  363. font-size: 28rpx;
  364. color: #ccc;
  365. }
  366. .itemCon{
  367. width: 388rpx;
  368. }
  369. .bnt{
  370. width: 180rpx;
  371. height: 54rpx;
  372. border-radius: 27rpx;
  373. color: var(--view-theme);
  374. border:1px solid var(--view-theme);
  375. font-size: 26rpx;
  376. position: absolute;
  377. right: 0;
  378. bottom: 16rpx;
  379. &.on{
  380. color: #666;
  381. border:unset;
  382. }
  383. }
  384. .code{
  385. width: 200rpx;
  386. }
  387. }
  388. .tip{
  389. font-size: 28rpx;
  390. color: #666;
  391. margin-top: 36rpx;
  392. }
  393. .info{
  394. font-size: 22rpx;
  395. color: #999;
  396. margin-top: 10rpx;
  397. }
  398. .picList{
  399. margin-top: 70rpx;
  400. .pictrue{
  401. width: 120rpx;
  402. height: 120rpx;
  403. margin: 0 0 35rpx 25rpx;
  404. position: relative;
  405. color: #D8D8D8;
  406. background-color: #F7F7F7;
  407. &:nth-of-type(4n-3){
  408. margin-left: 0;
  409. }
  410. image{
  411. width: 100%;
  412. height: 100%;
  413. border-radius: 8rpx;
  414. }
  415. .icon-guanbi1{
  416. font-size: 38rpx;
  417. position: absolute;
  418. top: -20rpx;
  419. right: -20rpx;
  420. }
  421. .icon-dizhi-tianjia{
  422. font-size: 38rpx;
  423. }
  424. }
  425. }
  426. .protocol {
  427. color: #999999;
  428. font-size: 24rpx;
  429. /deep/uni-checkbox .uni-checkbox-input{
  430. margin-top: -4rpx;
  431. width: 34rpx;
  432. height: 34rpx;
  433. }
  434. }
  435. .confirmBnt{
  436. font-size: 32rpx;
  437. width: 588rpx;
  438. height: 86rpx;
  439. border-radius: 43rpx;
  440. color: #fff;
  441. margin: 52rpx auto 0 auto;
  442. text-align: center;
  443. line-height: 86rpx;
  444. }
  445. }
  446. }
  447. </style>