index.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <!-- +---------------------------------------------------------------------- -->
  2. <!-- | CRMEB [ CRMEB赋能开发者,助力企业发展 ] -->
  3. <!-- +---------------------------------------------------------------------- -->
  4. <!-- | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. -->
  5. <!-- +---------------------------------------------------------------------- -->
  6. <!-- | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 -->
  7. <!-- +---------------------------------------------------------------------- -->
  8. <!-- | Author: CRMEB Team <admin@crmeb.com> -->
  9. <!-- +---------------------------------------------------------------------- -->
  10. {extend name="public/container" /}
  11. {block name="title"}申请成为讲师{/block}
  12. {block name="head"}
  13. <style>
  14. .tip {
  15. padding-left: .22rem;
  16. font-size: .2rem;
  17. color: #E93323;
  18. }
  19. input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button {
  20. -webkit-appearance: none;
  21. }
  22. </style>
  23. {/block}
  24. {block name="content"}
  25. <div v-cloak id="app" class="apply-lecturer">
  26. <form class="form">
  27. <label class="item">
  28. <div class="item-hd"><span>*</span>姓名</div>
  29. <input v-model.trim="formData.merchant_name" :disabled="applyStatus === 1" type="text" placeholder="请输入姓名" class="item-bd">
  30. </label>
  31. <label class="item">
  32. <div class="item-hd"><span>*</span>手机</div>
  33. <input v-model="formData.link_tel" :disabled="applyStatus === 1" type="tel" placeholder="请输入手机号" class="item-bd">
  34. </label>
  35. <div class="tip">注:成为讲师后可使用该手机号用短信登录讲师后台</div>
  36. <label v-if="applyStatus !== 1" class="item">
  37. <div class="item-hd"><span>*</span>验证码</div>
  38. <input v-model="formData.code" type="number" placeholder="请输入验证码" class="item-bd">
  39. <button :disabled="!!count" class="code-btn" type="button" @click="getCode">{{ count ? '重新获取(' + count + 's)' : '获取验证码' }}</button>
  40. </label>
  41. <div class="item">
  42. <div class="item-hd"><span>*</span>头像</div>
  43. <div class="item-bd">
  44. <div v-if="formData.merchant_head" class="img-wrap">
  45. <i v-if="formData.merchant_head && applyStatus !== 1" class="iconfont iconcha3" @click="deleteImage('merchant_head')"></i>
  46. <img v-if="formData.merchant_head" :src="formData.merchant_head">
  47. </div>
  48. <label v-else class="upload">
  49. <input type="file" accept="image/jpg,image/jpeg,image/png" hidden @change="upload('merchant_head', $event)">
  50. </label>
  51. </div>
  52. </div>
  53. <label class="item">
  54. <div class="item-hd"><span>*</span>领域<i class="iconfont iconzhuyi-copy" @click.prevent="labelAlert"></i></div>
  55. <input v-model.trim="label" :disabled="applyStatus === 1" type="text" placeholder="请填写" class="item-bd">
  56. </label>
  57. <label class="item">
  58. <div class="item-hd"><span>*</span>地区</div>
  59. <input :disabled="applyStatus === 1" :value="formData.province + formData.city + formData.district" type="text" placeholder="请选择" class="item-bd" readonly @focus="show = true">
  60. <i class="iconfont icondidian"></i>
  61. </label>
  62. <label class="item">
  63. <div class="item-hd"><span>*</span>地址</div>
  64. <input v-model.trim="formData.address" :disabled="applyStatus === 1" type="text" placeholder="请输入详细地址" class="item-bd">
  65. </label>
  66. <label class="item">
  67. <div class="item-hd"><span>*</span>简介</div>
  68. <input v-model.trim="formData.explain" :disabled="applyStatus === 1" type="text" placeholder="最多20个字" maxlength="20" class="item-bd">
  69. </label>
  70. <div class="intro-item">
  71. <div class="item-hd">
  72. <div class="item-hd-lt"><span>*</span>介绍</div>
  73. <div class="item-hd-rt">{{ formData.introduction.length }}/2000</div>
  74. </div>
  75. <textarea v-model.trim="formData.introduction" :disabled="applyStatus === 1" placeholder="请填写讲师介绍" class="item-bd" rows="3"></textarea>
  76. </div>
  77. <div v-if="!(applyStatus === 1 && !formData.charter.length)" class="honor-item">
  78. <div class="item-hd">
  79. <div>请上传所获得的荣誉证书及相关资质证书</div>
  80. <div class="tip">(图片格式支持JPG、PNG、JPEG,最多上传4张)</div>
  81. </div>
  82. <div class="item-bd">
  83. <div v-for="item in formData.charter" :key="item" class="img-wrap">
  84. <i v-if="applyStatus !== 1" class="iconfont iconcha3" @click="deleteImage('charter', item)"></i>
  85. <img :src="item">
  86. </div>
  87. <label v-if="formData.charter.length < 4 && applyStatus !== 1" class="upload">
  88. <input type="file" accept="image/jpg,image/jpeg,image/png" hidden @change="upload('charter', $event)">
  89. </label>
  90. </div>
  91. </div>
  92. <div v-if="applyStatus !== 1" class="agree-item"><i :class="[agree ? 'iconxuanzhong1' : 'iconweixuanzhong', 'iconfont']" @click="agree = !agree"></i>已阅读并同意<button class="agree-btn" type="button" @click="agreeVisible = true">《{$title}》</button></div>
  93. <button v-if="applyStatus !== 1" class="btn" type="button" @click="submitApply">提交申请</button>
  94. </form>
  95. <div :class="{ mask: agreeVisible }"></div>
  96. <!-- 协议弹窗 -->
  97. <div :class="{ show: agreeVisible }" class="agree-dialog">
  98. <div class="title">{$title}</div>
  99. <div class="content">{$content}</div>
  100. <!-- <div class="content"><img class="empty" src="{__WAP_PATH}zsff/images/empty.png"></div> -->
  101. <button class="ok" type="button" @click="agreeVisible = false,agree = true">我同意</button>
  102. <button class="no" type="button" @click="agreeVisible = false,agree = false">不同意</button>
  103. <i class="iconfont iconcha3" @click="agreeVisible = false"></i>
  104. </div>
  105. <!-- 申请讲师状态 -->
  106. <apply-dialog :show.sync="applyVisible" :status="applyStatus"></apply-dialog>
  107. <quick-menu></quick-menu>
  108. <yd-cityselect v-model="show" :ready="ready" :provance="formData.province" :city="formData.city" :area="formData.district" :callback="citySelectCallback" :items="district" />
  109. </div>
  110. {/block}
  111. {block name="foot"}
  112. <script>
  113. require(['vue', 'helper', 'store', 'ydui', 'static/plug/ydui/province_city_area', 'components/apply-dialog/index', 'layer', 'quick'], function (Vue, $h, store, ydui, district, ApplyDialog) {
  114. Vue.use(ydui.default);
  115. var COUNT = 60;
  116. new Vue({
  117. el: '#app',
  118. components: {
  119. 'apply-dialog': ApplyDialog
  120. },
  121. data: {
  122. formData: {
  123. merchant_name: '',
  124. link_tel: '',
  125. code: '',
  126. merchant_head: '',
  127. province: '',
  128. city: '',
  129. district: '',
  130. address: '',
  131. explain: '',
  132. introduction: '',
  133. charter: []
  134. },
  135. district: district,
  136. label: '',
  137. show: false,
  138. ready: false,
  139. count: 0,
  140. agree: false,
  141. agreeVisible: false,
  142. applyStatus: null,
  143. applyVisible: false
  144. },
  145. watch: {
  146. 'formData.introduction': function (value) {
  147. if (value.length > 2000) {
  148. this.formData.introduction = value.slice(0, 2000);
  149. }
  150. }
  151. },
  152. created: function () {
  153. this.is_apply();
  154. },
  155. methods: {
  156. // 上传图片
  157. upload: function (name, event) {
  158. var vm = this;
  159. var files = event.target.files;
  160. if (!files.length) {
  161. return false;
  162. }
  163. if (['image/jpg', 'image/jpeg', 'image/png'].indexOf(files[0].type) === -1) {
  164. return layer.msg('请上传JPG、PNG、JPEG格式的图片');
  165. }
  166. var formData = new FormData();
  167. formData.append('file', files[0]);
  168. var index = layer.load(1);
  169. store.basePost($h.U({
  170. c: 'auth_api',
  171. a: 'upload'
  172. }), formData, function (res) {
  173. layer.close(index);
  174. event.target.value = '';
  175. if (typeof vm.formData[name] === 'string') {
  176. vm.formData[name] = res.data.data.url;
  177. } else {
  178. vm.formData[name].push(res.data.data.url);
  179. }
  180. }, function (err) {
  181. layer.close(index);
  182. layer.msg(err, function () {
  183. event.target.value = '';
  184. });
  185. }, true);
  186. },
  187. // 删除图片
  188. deleteImage: function (name, url) {
  189. if (typeof this.formData[name] === 'string') {
  190. this.formData[name] = '';
  191. } else if (Array.isArray(this.formData[name])) {
  192. this.formData[name].splice(this.formData[name].indexOf(url), 1);
  193. }
  194. },
  195. // 选择地区
  196. citySelectCallback: function (data) {
  197. this.formData.province = data.itemName1;
  198. this.formData.city = data.itemName2;
  199. this.formData.district = data.itemName3;
  200. },
  201. // 提交申请
  202. submitApply: function () {
  203. var vm = this;
  204. if (!this.formData.merchant_name) {
  205. return $h.pushMsg('请输入姓名');
  206. }
  207. if (!this.formData.link_tel) {
  208. return $h.pushMsg('请输入手机号');
  209. }
  210. if (!/^1[3456789]\d{9}$/.test(this.formData.link_tel)) {
  211. return $h.pushMsg('请输入正确的手机号');
  212. }
  213. if (!this.formData.code) {
  214. return $h.pushMsg('请输入验证码');
  215. }
  216. if (!this.formData.merchant_head) {
  217. return $h.pushMsg('请上传头像');
  218. }
  219. if (!this.label) {
  220. return $h.pushMsg('请填写标签');
  221. }
  222. var label = this.label.split(this.label.indexOf(',') === -1 ? ',' : ',');
  223. var labelLen = label.length;
  224. if (labelLen > 3) {
  225. return $h.pushMsg('可添加1-3个领域');
  226. }
  227. for (var i = 0; i < labelLen; i++) {
  228. if (!label[i].length || label[i].length > 6) {
  229. return $h.pushMsg('每个标签1-6个字');
  230. }
  231. }
  232. if (!this.formData.province) {
  233. return $h.pushMsg('请选择地址');
  234. }
  235. if (!this.formData.explain) {
  236. return $h.pushMsg('请输入讲师说明');
  237. }
  238. if (!this.formData.introduction) {
  239. return $h.pushMsg('请填写讲师介绍');
  240. }
  241. if (!this.agree) {
  242. return $h.pushMsg('请勾选讲师入驻协议');
  243. }
  244. this.formData.label = label;
  245. var index = layer.load(1);
  246. store.basePost($h.U({
  247. c: 'merchant',
  248. a: 'apply'
  249. }), this.formData, function (res) {
  250. layer.close(index);
  251. vm.applyVisible = true;
  252. vm.applyStatus = 0;
  253. }, function (err) {
  254. layer.close(index);
  255. layer.msg(err);
  256. }, true);
  257. },
  258. // 申请状态
  259. is_apply: function () {
  260. var vm = this;
  261. store.baseGet($h.U({
  262. c: 'merchant',
  263. a: 'is_apply'
  264. }), function (res) {
  265. if (res.data.data) {
  266. vm.applyStatus = res.data.data.status;
  267. if (res.data.data.status === 2) {
  268. vm.ready = true;
  269. } else {
  270. vm.apply_data();
  271. }
  272. } else {
  273. vm.ready = true;
  274. }
  275. });
  276. },
  277. // 申请数据
  278. apply_data: function () {
  279. var vm = this;
  280. store.baseGet($h.U({
  281. c: 'merchant',
  282. a: 'apply_data'
  283. }), function (res) {
  284. var data = res.data.data;
  285. vm.formData = data;
  286. vm.label = data.label.join();
  287. vm.ready = true;
  288. });
  289. },
  290. // 添加领域规则弹窗
  291. labelAlert: function () {
  292. layer.alert('格式:领域一,领域二<br>领域之间用逗号分隔<br>每个领域1-6个字<br>可添加1-3个领域', {
  293. title: false,
  294. closeBtn: false,
  295. btnAlign: 'c',
  296. btn: '知道了'
  297. });
  298. },
  299. // 获取验证码
  300. getCode: function () {
  301. var vm = this;
  302. var timer;
  303. if (!this.formData.link_tel) {
  304. return $h.pushMsg('请输入手机号');
  305. }
  306. if (!/^1[3456789]\d{9}$/.test(this.formData.link_tel)) {
  307. return $h.pushMsg('请输入正确的手机号');
  308. }
  309. timer = setInterval(function () {
  310. vm.count--;
  311. if (!vm.count) {
  312. clearInterval(timer);
  313. timer = null;
  314. }
  315. }, 1e3);
  316. this.count = COUNT;
  317. var index = layer.load(1);
  318. store.baseGet($h.U({
  319. c: 'auth_api',
  320. a: 'code',
  321. q: {
  322. phone: this.formData.link_tel
  323. }
  324. }), function (res) {
  325. layer.close(index);
  326. layer.msg(res.data.msg);
  327. }, function (err) {
  328. if (timer) {
  329. clearInterval(timer);
  330. timer = null;
  331. vm.count = 0;
  332. }
  333. layer.msg(err);
  334. }, true);
  335. }
  336. }
  337. });
  338. });
  339. </script>
  340. {/block}