index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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:'111',
  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. type:1,
  223. }).then(res => {
  224. uni.reLaunch({
  225. url: '/pages/users/store_state/index?id='+ res.data.id
  226. })
  227. }).catch(err => {
  228. return this.$util.Tips({
  229. title: err
  230. });
  231. });
  232. },
  233. ChangeIsDefault(e) {
  234. this.$set(this, 'protocol', !this.protocol);
  235. },
  236. supplierApply(){
  237. userApply(this.id).then(res=>{
  238. let data = res.data;
  239. this.system_name = data.system_name;
  240. this.name = data.name;
  241. this.phone = data.phone;
  242. this.pics = data.images;
  243. }).catch(err=>{
  244. return this.$util.Tips({
  245. title: err
  246. });
  247. })
  248. },
  249. record(){
  250. uni.navigateTo({
  251. url: '/pages/users/store_record_list/index'
  252. })
  253. },
  254. /**
  255. * 删除图片
  256. *
  257. */
  258. DelPic(index) {
  259. let that = this,
  260. pic = this.pics[index];
  261. let pics = that.pics.slice(0,10);
  262. pics.splice(index, 1);
  263. that.$set(that, 'pics', pics);
  264. },
  265. /**
  266. * 上传文件
  267. *
  268. */
  269. uploadpic() {
  270. let that = this;
  271. this.canvasStatus = true
  272. that.$util.uploadImageChange({count:8,url:'upload/image'}, function(res) {
  273. that.pics.push(res.data.url);
  274. }, (res) => {
  275. this.canvasStatus = false
  276. }, (res) => {
  277. this.canvasWidth = res.w
  278. this.canvasHeight = res.h
  279. });
  280. },
  281. /**
  282. * 发送验证码
  283. *
  284. */
  285. code(data) {
  286. let that = this;
  287. if (!that.protocol) {
  288. this.inAnimation = true
  289. return that.$util.Tips({
  290. title: '请先阅读并同意协议'
  291. });
  292. }
  293. if (!that.phone) return that.$util.Tips({
  294. title: '请填写手机号码'
  295. });
  296. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone)) return that.$util.Tips({
  297. title: '请输入正确的手机号码'
  298. });
  299. this.$refs.verify.show()
  300. },
  301. getAgreement(){
  302. this.$refs.supplier.getAgreement();
  303. this.showAgree = true;
  304. },
  305. close(){
  306. this.showAgree = false;
  307. }
  308. }
  309. }
  310. </script>
  311. <style lang="scss">
  312. .supplier{
  313. height: 100vh;
  314. background-color: var(--view-theme);
  315. padding-bottom: 10rpx;
  316. .conters{
  317. background-color: var(--view-theme);
  318. padding-bottom: 10rpx;
  319. }
  320. .header{
  321. width: 750rpx;
  322. height: 400rpx;
  323. position: relative;
  324. image{
  325. width: 100%;
  326. height: 100%;
  327. }
  328. .record{
  329. position: absolute;
  330. right: 0;
  331. top:0;
  332. width: 144rpx;
  333. height: 44rpx;
  334. color: #FFDDB8;
  335. background-color: rgba(0, 0, 0, 0.3);
  336. border-radius: 22rpx 0 0 22rpx;
  337. font-size: 24rpx;
  338. padding-left: 6rpx;
  339. margin-top: 22rpx;
  340. .iconfont{
  341. font-size: 18rpx;
  342. margin-left: 6rpx;
  343. }
  344. }
  345. }
  346. .list{
  347. width: 690rpx;
  348. background-color: #fff;
  349. margin: -108rpx auto 0 auto;
  350. border-radius: 24rpx;
  351. position: relative;
  352. z-index: 1;
  353. padding: 20rpx 51rpx 72rpx 51rpx;
  354. .item{
  355. height: 104rpx;
  356. border-bottom: 1px solid #E9E9E9;
  357. padding-bottom: 22rpx;
  358. position: relative;
  359. input{
  360. width: 388rpx;
  361. font-size: 28rpx;
  362. }
  363. .placeholder{
  364. font-size: 28rpx;
  365. color: #ccc;
  366. }
  367. .itemCon{
  368. width: 388rpx;
  369. }
  370. .bnt{
  371. width: 180rpx;
  372. height: 54rpx;
  373. border-radius: 27rpx;
  374. color: var(--view-theme);
  375. border:1px solid var(--view-theme);
  376. font-size: 26rpx;
  377. position: absolute;
  378. right: 0;
  379. bottom: 16rpx;
  380. &.on{
  381. color: #666;
  382. border:unset;
  383. }
  384. }
  385. .code{
  386. width: 200rpx;
  387. }
  388. }
  389. .tip{
  390. font-size: 28rpx;
  391. color: #666;
  392. margin-top: 36rpx;
  393. }
  394. .info{
  395. font-size: 22rpx;
  396. color: #999;
  397. margin-top: 10rpx;
  398. }
  399. .picList{
  400. margin-top: 70rpx;
  401. .pictrue{
  402. width: 120rpx;
  403. height: 120rpx;
  404. margin: 0 0 35rpx 25rpx;
  405. position: relative;
  406. color: #D8D8D8;
  407. background-color: #F7F7F7;
  408. &:nth-of-type(4n-3){
  409. margin-left: 0;
  410. }
  411. image{
  412. width: 100%;
  413. height: 100%;
  414. border-radius: 8rpx;
  415. }
  416. .icon-guanbi1{
  417. font-size: 38rpx;
  418. position: absolute;
  419. top: -20rpx;
  420. right: -20rpx;
  421. }
  422. .icon-dizhi-tianjia{
  423. font-size: 38rpx;
  424. }
  425. }
  426. }
  427. .protocol {
  428. color: #999999;
  429. font-size: 24rpx;
  430. /deep/uni-checkbox .uni-checkbox-input{
  431. margin-top: -4rpx;
  432. width: 34rpx;
  433. height: 34rpx;
  434. }
  435. }
  436. .confirmBnt{
  437. font-size: 32rpx;
  438. width: 588rpx;
  439. height: 86rpx;
  440. border-radius: 43rpx;
  441. color: #fff;
  442. margin: 52rpx auto 0 auto;
  443. text-align: center;
  444. line-height: 86rpx;
  445. }
  446. }
  447. }
  448. </style>