index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view>
  3. <view class="w-full fixed-lt z-20" :style="{'padding-top': sysHeight + 'px'}">
  4. <view class="h-80 px-20 flex-between-center">
  5. <text class="iconfont icon-ic_leftarrow fs-40 text--w111-fff" @tap="pageBack"></text>
  6. </view>
  7. </view>
  8. <view class="header-top relative" :style="[headerBg]">
  9. <view class="rule-btn w-124 flex-center fs-24 text--w111-fff" :style="{top: 100 + sysHeight + 'px'}"
  10. @tap="goRecord">申请记录</view>
  11. </view>
  12. <view class="bg-v-gradient pl-20 pr-20 pb-24" :style="{minHeight: mainHeight + 'px'}">
  13. <view class="bg--w111-fff rd-24rpx content-box">
  14. <view class="fs-30 fw-500 lh-42rpx">请填写以下信息</view>
  15. <view class="cell flex-between-center mt-64">
  16. <view class="fs-28 lh-40rpx">供应商名称</view>
  17. <input type="text" v-model="form.system_name" placeholder="请输入代理商名称" placeholder-class="text--w111-ccc" class="fs-28 text-right" />
  18. </view>
  19. <view class="cell flex-between-center mt-64">
  20. <view class="fs-28 lh-40rpx">用户姓名</view>
  21. <input type="text" v-model="form.name" placeholder="请输入姓名" placeholder-class="text--w111-ccc" class="fs-28 text-right" />
  22. </view>
  23. <view class="cell flex-between-center mt-64">
  24. <view class="fs-28 lh-40rpx">联系电话</view>
  25. <input type="number" v-model="form.phone" placeholder="请输入手机号" placeholder-class="text--w111-ccc" class="fs-28 text-right" />
  26. </view>
  27. <view class="cell flex-between-center mt-64">
  28. <view class="fs-28 lh-40rpx">验证码</view>
  29. <view class="flex-y-center">
  30. <input type="number" v-model="form.captcha" placeholder="请输入验证码" placeholder-class="text--w111-ccc" class="fs-28 text-right" />
  31. <button class="code-btn w-168 h-56 flex-center fs-24 ml-20"
  32. :disabled="disabled" @tap="code">{{ text }}</button>
  33. </view>
  34. </view>
  35. <view class="fs-28 lh-40rpx mt-64">请上传营业执照及相关资质证明图片</view>
  36. <view class="fs-24 lh-34rpx text--w111-ccc mt-12">(图片最多可上传8张,图片格式支持JPJ、PNG、JPEG)</view>
  37. <view class="grid-column-4 grid-gap-24rpx mt-24">
  38. <view class="relative w-148 h-148" v-for="(item,index) in form.images" :key="index">
  39. <image :src="item" mode="aspectFill" class="w-148 h-148 rd-16rpx"></image>
  40. <view class="abs-rt w-32 h-32 del-pic flex-center" @click="DelPic(index)">
  41. <text class="iconfont icon-ic_close text--w111-fff fs-24"></text>
  42. </view>
  43. </view>
  44. <view class="h-148 flex-col flex-center upload bg--w111-f5f5f5 text--w111-999 rd-16rpx"
  45. @click='uploadpic' v-if="form.images.length < 8">
  46. <text class="iconfont icon-ic_camera fs-42"></text>
  47. <text class="fs-24 lh-34rpx pt-8">上传图片</text>
  48. </view>
  49. </view>
  50. <view class="flex-y-center mt-32">
  51. <text class="iconfont fs-30" :class="isSelect ? 'icon-a-ic_CompleteSelect' : 'icon-ic_unselect'" @tap="proviceSelect"></text>
  52. <text class="fs-24 text--w111-999 pl-12">已阅读并同意</text>
  53. <text class="font-red fs-24" @tap="getAgreement">《供应商协议》</text>
  54. </view>
  55. <view class="w-full h-88 rd-44rpx flex-center text--w111-fff fs-28 mt-48"
  56. :class="isSelectStar ? 'bg-red' : 'bg-disabled'" @tap="submitSupply">提交申请</view>
  57. </view>
  58. </view>
  59. <Verify @success="success" captchaType="blockPuzzle" :imgSize="{ width: '330px', height: '155px' }"
  60. ref="verify"></Verify>
  61. <tui-modal :show="showModal" maskClosable custom @cancel="hideModal">
  62. <view class="tui-modal-custom" @touchmove.stop.prevent>
  63. <view class="fs-32 fw-500 lh-44rpx text-center">供应商协议</view>
  64. <view class="fs-28 text--w111-666 lh-44rpx mt-24">
  65. <scroll-view scroll-y="true" style="max-height: 700rpx">
  66. <jyf-parser :html="supplierAgreement" ref="article" :tag-style="tagStyle"></jyf-parser>
  67. </scroll-view>
  68. </view>
  69. <view class="w-full h-72 rd-36rpx flex-center bg-red fs-26 text--w111-fff mt-32" @tap="hideModal">知道了</view>
  70. </view>
  71. </tui-modal>
  72. </view>
  73. </template>
  74. <script>
  75. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  76. import {toLogin} from '@/libs/login.js';
  77. import {mapGetters} from "vuex";
  78. import { spplyCreateApi, getCodeApi, registerVerify, userApply, getUserAgreement } from "@/api/user.js";
  79. import colors from "@/mixins/color";
  80. import sendVerifyCode from "@/mixins/SendVerifyCode";
  81. import { HTTP_REQUEST_URL } from '@/config/app';
  82. import Verify from '../components/verify/verify.vue';
  83. import tuiModal from "@/components/tui-modal/index.vue";
  84. import parser from "@/components/jyf-parser/jyf-parser";
  85. export default {
  86. data() {
  87. return {
  88. sysHeight:sysHeight,
  89. form:{
  90. system_name:'',
  91. name:'',
  92. phone:'',
  93. captcha:'',
  94. images:[]
  95. },
  96. canvasWidth: "",
  97. canvasHeight: "",
  98. canvasStatus: false,
  99. isSelect: false,
  100. keyCode:'',
  101. id:0,
  102. showModal: false,
  103. supplierAgreement:'',
  104. tagStyle:{
  105. img: 'width:100%;display:block;',
  106. }
  107. }
  108. },
  109. components: {
  110. Verify,
  111. tuiModal,
  112. parser
  113. },
  114. mixins: [sendVerifyCode, colors],
  115. watch: {
  116. isLogin: {
  117. handler: function(newV, oldV) {
  118. if (newV) {
  119. // #ifndef MP
  120. this.getOrderProduct();
  121. // #endif
  122. }
  123. },
  124. deep: true
  125. }
  126. },
  127. computed:{
  128. ...mapGetters(['isLogin']),
  129. isSelectStar(){
  130. if(this.form.system_name && this.form.name && this.form.phone && this.form.captcha && this.form.images.length ) return true
  131. },
  132. headerBg(){
  133. return {
  134. backgroundImage: 'url('+ HTTP_REQUEST_URL + '/statics/images/supplier/apply_header.png'+')'
  135. }
  136. },
  137. mainHeight(){
  138. let {windowHeight } = uni.getSystemInfoSync();
  139. return windowHeight - 90 - this.sysHeight
  140. }
  141. },
  142. onLoad(options) {
  143. this.id = options.id || 0;
  144. if(options.id){
  145. this.getInfo();
  146. }
  147. },
  148. methods: {
  149. /*** 删除图片* */
  150. DelPic: function(index) {
  151. let that = this, pic = this.form.images[index];
  152. that.form.images.splice(index, 1);
  153. that.$set(that.form, 'images', that.form.images);
  154. },
  155. /*** 上传文件 **/
  156. uploadpic: function() {
  157. let that = this;
  158. this.canvasStatus = true
  159. that.$util.uploadImageChange({count:8,url:'upload/image'}, function(res) {
  160. that.form.images.push(res.data.url);
  161. }, (res) => {
  162. this.canvasStatus = false
  163. }, (res) => {
  164. this.canvasWidth = res.w
  165. this.canvasHeight = res.h
  166. });
  167. },
  168. code(){
  169. if (!this.form.phone) return that.$util.Tips({
  170. title: '请填写手机号码'
  171. });
  172. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.form.phone)) return this.$util.Tips({
  173. title: '请输入正确的手机号码'
  174. });
  175. this.$refs.verify.show()
  176. },
  177. success(data) {
  178. this.$refs.verify.hide()
  179. getCodeApi()
  180. .then(res => {
  181. this.keyCode = res.data.key;
  182. this.getCode(data);
  183. })
  184. .catch(res => {
  185. this.$util.Tips({
  186. title: res
  187. });
  188. });
  189. },
  190. async getCode(data){
  191. let that = this;
  192. if (!this.form.phone) return that.$util.Tips({
  193. title: '请填写手机号码'
  194. });
  195. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.form.phone)) return this.$util.Tips({
  196. title: '请输入正确的手机号码'
  197. });
  198. await registerVerify({
  199. phone: that.form.phone,
  200. type: 'supplier',
  201. key: that.keyCode,
  202. captchaType: 'blockPuzzle',
  203. captchaVerification: data.captchaVerification
  204. })
  205. .then(res => {
  206. that.$util.Tips({
  207. title: res.msg
  208. });
  209. that.sendCode();
  210. })
  211. .catch(res => {
  212. that.$util.Tips({
  213. title: res
  214. });
  215. });
  216. },
  217. proviceSelect(){
  218. this.isSelect = !this.isSelect;
  219. },
  220. getInfo(){
  221. userApply(this.id).then(res=>{
  222. let data = res.data;
  223. this.form.system_name = data.system_name;
  224. this.form.name = data.name;
  225. this.form.phone = data.phone;
  226. this.form.images = data.images;
  227. }).catch(err=>{
  228. return this.$util.Tips({
  229. title: err
  230. });
  231. })
  232. },
  233. submitSupply(){
  234. if(!this.isSelectStar) return this.$util.Tips({
  235. title: '请完整填写表单信息'
  236. });
  237. if(!this.isSelect) return this.$util.Tips({
  238. title: '请阅读并同意协议'
  239. });
  240. spplyCreateApi(this.id,this.form).then(res=>{
  241. uni.showToast({
  242. title:res.msg
  243. })
  244. uni.navigateTo({
  245. url: '/pages/users/supplier/state?id='+ res.data.id
  246. })
  247. }).catch(err => {
  248. return this.$util.Tips({
  249. title: err
  250. });
  251. });
  252. },
  253. pageBack(){
  254. uni.navigateBack()
  255. },
  256. goRecord(){
  257. uni.navigateTo({
  258. url: '/pages/users/supplier/record'
  259. })
  260. },
  261. getAgreement(){
  262. getUserAgreement('supplier').then(res => {
  263. this.supplierAgreement = res.data.content;
  264. this.showModal = true;
  265. }).catch(err => {
  266. that.$util.Tips({
  267. title: err.msg
  268. });
  269. })
  270. },
  271. hideModal(){
  272. this.showModal = false;
  273. },
  274. }
  275. }
  276. </script>
  277. <style>
  278. .header-top{
  279. width: 100%;
  280. height: 358rpx;
  281. background-size: cover;
  282. }
  283. .rule-btn{
  284. height: 48rpx;
  285. background: rgba(0,0,0,0.15);
  286. border-radius: 24rpx 0 0 24rpx;
  287. position: absolute;
  288. right: 0;
  289. }
  290. .bg-v-gradient{
  291. background: linear-gradient(180deg, #FE7015 0%, #EB3B26 100%);
  292. }
  293. .content-box{
  294. padding: 48rpx 32rpx 40rpx;
  295. }
  296. .code-btn{
  297. border: 1px solid #e93323;
  298. color: #e93323;
  299. border-radius: 28rpx;
  300. font-family: PingFang SC, PingFang SC;
  301. font-weight: 500;
  302. }
  303. .upload{
  304. border: 1rpx dashed #ccc;
  305. }
  306. .del-pic{
  307. background-color: #999;
  308. border-radius: 0 16rpx 0 16rpx;
  309. }
  310. .icon-a-ic_CompleteSelect, .font-red{
  311. color: #e93323;
  312. }
  313. .icon-ic_unselect{
  314. color: #ccc;
  315. }
  316. .bg-red{
  317. background-color: #e93323;
  318. }
  319. .bg-disabled{
  320. background-color: rgba(233, 51, 35, 0.5);
  321. }
  322. .modal-bottom{
  323. height: 136rpx;
  324. border-radius: 0 0 32rpx 32rpx;
  325. background-color: #fff;
  326. }
  327. </style>