index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. //#ifndef MP
  147. toLogin();
  148. //#endif
  149. //#ifdef MP
  150. this.isShowAuth = true;
  151. //#endif
  152. }
  153. },
  154. methods:{
  155. /**
  156. * 授权回调
  157. */
  158. onLoadFun(e) {
  159. this.isShowAuth = false;
  160. },
  161. // 授权关闭
  162. authColse(e) {
  163. this.isShowAuth = e
  164. },
  165. success(data) {
  166. this.$refs.verify.hide()
  167. getCodeApi()
  168. .then(res => {
  169. this.keyCode = res.data.key;
  170. this.getCode(data);
  171. })
  172. .catch(res => {
  173. this.$util.Tips({
  174. title: res
  175. });
  176. });
  177. },
  178. async getCode(data){
  179. let that = this;
  180. await registerVerify({
  181. phone: that.phone,
  182. type: 'supplier',
  183. key: that.keyCode,
  184. captchaType: 'blockPuzzle',
  185. captchaVerification: data.captchaVerification,
  186. })
  187. .then(res => {
  188. that.$util.Tips({
  189. title: res.msg
  190. });
  191. that.sendCode();
  192. })
  193. .catch(res => {
  194. that.$util.Tips({
  195. title: res
  196. });
  197. });
  198. },
  199. formSubmit() {
  200. if (!this.protocol) {
  201. this.inAnimation = true
  202. return this.$util.Tips({
  203. title: '请先阅读并同意协议'
  204. });
  205. }
  206. if (!this.system_name) return this.$util.Tips({
  207. title: '请输入供应商名称'
  208. });
  209. if (!this.name) return this.$util.Tips({
  210. title: '请输入联系人姓名'
  211. });
  212. if (!this.phone) return this.$util.Tips({
  213. title: '请填写手机号码'
  214. });
  215. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.phone)) return this.$util.Tips({
  216. title: '请输入正确的手机号码'
  217. });
  218. if (!this.captcha) return this.$util.Tips({
  219. title: '请输入验证码'
  220. });
  221. applySupplier(this.id,{
  222. system_name: this.system_name,
  223. name: this.name,
  224. phone: this.phone,
  225. captcha: this.captcha,
  226. images: this.pics.slice(0,10)
  227. }).then(res => {
  228. uni.reLaunch({
  229. url: '/pages/users/supplier_state/index?id='+ res.data.id
  230. })
  231. }).catch(err => {
  232. return this.$util.Tips({
  233. title: err
  234. });
  235. });
  236. },
  237. ChangeIsDefault(e) {
  238. this.$set(this, 'protocol', !this.protocol);
  239. },
  240. supplierApply(){
  241. userApply(this.id).then(res=>{
  242. let data = res.data;
  243. this.system_name = data.system_name;
  244. this.name = data.name;
  245. this.phone = data.phone;
  246. this.pics = data.images;
  247. }).catch(err=>{
  248. return this.$util.Tips({
  249. title: err
  250. });
  251. })
  252. },
  253. record(){
  254. uni.navigateTo({
  255. url: '/pages/users/record_list/index'
  256. })
  257. },
  258. /**
  259. * 删除图片
  260. *
  261. */
  262. DelPic(index) {
  263. let that = this,
  264. pic = this.pics[index];
  265. let pics = that.pics.slice(0,10);
  266. pics.splice(index, 1);
  267. that.$set(that, 'pics', pics);
  268. },
  269. /**
  270. * 上传文件
  271. *
  272. */
  273. uploadpic() {
  274. let that = this;
  275. this.canvasStatus = true
  276. that.$util.uploadImageChange({count:8,url:'upload/image'}, function(res) {
  277. that.pics.push(res.data.url);
  278. }, (res) => {
  279. this.canvasStatus = false
  280. }, (res) => {
  281. this.canvasWidth = res.w
  282. this.canvasHeight = res.h
  283. });
  284. },
  285. /**
  286. * 发送验证码
  287. *
  288. */
  289. code(data) {
  290. let that = this;
  291. if (!that.protocol) {
  292. this.inAnimation = true
  293. return that.$util.Tips({
  294. title: '请先阅读并同意协议'
  295. });
  296. }
  297. if (!that.phone) return that.$util.Tips({
  298. title: '请填写手机号码'
  299. });
  300. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone)) return that.$util.Tips({
  301. title: '请输入正确的手机号码'
  302. });
  303. this.$refs.verify.show()
  304. },
  305. getAgreement(){
  306. this.$refs.supplier.getAgreement();
  307. this.showAgree = true;
  308. },
  309. close(){
  310. this.showAgree = false;
  311. }
  312. }
  313. }
  314. </script>
  315. <style lang="scss">
  316. .supplier{
  317. height: 100vh;
  318. background-color: var(--view-theme);
  319. padding-bottom: 10rpx;
  320. .conters{
  321. background-color: var(--view-theme);
  322. padding-bottom: 10rpx;
  323. }
  324. .header{
  325. width: 750rpx;
  326. height: 400rpx;
  327. position: relative;
  328. image{
  329. width: 100%;
  330. height: 100%;
  331. }
  332. .record{
  333. position: absolute;
  334. right: 0;
  335. top:0;
  336. width: 144rpx;
  337. height: 44rpx;
  338. color: #FFDDB8;
  339. background-color: rgba(0, 0, 0, 0.3);
  340. border-radius: 22rpx 0 0 22rpx;
  341. font-size: 24rpx;
  342. padding-left: 6rpx;
  343. margin-top: 22rpx;
  344. .iconfont{
  345. font-size: 18rpx;
  346. margin-left: 6rpx;
  347. }
  348. }
  349. }
  350. .list{
  351. width: 690rpx;
  352. background-color: #fff;
  353. margin: -108rpx auto 0 auto;
  354. border-radius: 24rpx;
  355. position: relative;
  356. z-index: 1;
  357. padding: 20rpx 51rpx 72rpx 51rpx;
  358. .item{
  359. height: 104rpx;
  360. border-bottom: 1px solid #E9E9E9;
  361. padding-bottom: 22rpx;
  362. position: relative;
  363. input{
  364. width: 388rpx;
  365. font-size: 28rpx;
  366. }
  367. .placeholder{
  368. font-size: 28rpx;
  369. color: #ccc;
  370. }
  371. .itemCon{
  372. width: 388rpx;
  373. }
  374. .bnt{
  375. width: 180rpx;
  376. height: 54rpx;
  377. border-radius: 27rpx;
  378. color: var(--view-theme);
  379. border:1px solid var(--view-theme);
  380. font-size: 26rpx;
  381. position: absolute;
  382. right: 0;
  383. bottom: 16rpx;
  384. &.on{
  385. color: #666;
  386. border:unset;
  387. }
  388. }
  389. .code{
  390. width: 200rpx;
  391. }
  392. }
  393. .tip{
  394. font-size: 28rpx;
  395. color: #666;
  396. margin-top: 36rpx;
  397. }
  398. .info{
  399. font-size: 22rpx;
  400. color: #999;
  401. margin-top: 10rpx;
  402. }
  403. .picList{
  404. margin-top: 70rpx;
  405. .pictrue{
  406. width: 120rpx;
  407. height: 120rpx;
  408. margin: 0 0 35rpx 25rpx;
  409. position: relative;
  410. color: #D8D8D8;
  411. background-color: #F7F7F7;
  412. &:nth-of-type(4n-3){
  413. margin-left: 0;
  414. }
  415. image{
  416. width: 100%;
  417. height: 100%;
  418. border-radius: 8rpx;
  419. }
  420. .icon-guanbi1{
  421. font-size: 38rpx;
  422. position: absolute;
  423. top: -20rpx;
  424. right: -20rpx;
  425. }
  426. .icon-dizhi-tianjia{
  427. font-size: 38rpx;
  428. }
  429. }
  430. }
  431. .protocol {
  432. color: #999999;
  433. font-size: 24rpx;
  434. /deep/uni-checkbox .uni-checkbox-input{
  435. margin-top: -4rpx;
  436. width: 34rpx;
  437. height: 34rpx;
  438. }
  439. }
  440. .confirmBnt{
  441. font-size: 32rpx;
  442. width: 588rpx;
  443. height: 86rpx;
  444. border-radius: 43rpx;
  445. color: #fff;
  446. margin: 52rpx auto 0 auto;
  447. text-align: center;
  448. line-height: 86rpx;
  449. }
  450. }
  451. }
  452. </style>