1
0

edit.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <app-layout>
  3. <view>
  4. <!-- 申请页面背景图片以及待审核页面背景图片 -->
  5. <image :src="custom_setting.apply.apply_head_pic" class="add-bg"></image>
  6. <!-- 未在申请分销商 -->
  7. <view class="add-form">
  8. <view class="add-default">
  9. <view class="add-info">
  10. <view class="add-label">
  11. <text style="color: #ff4544">*</text>姓名
  12. </view>
  13. <view class="add-input">
  14. <input v-model="name" placeholder="请填写真实姓名" placeholder-style="font-size: 20rpx;color: #cdcdcd" />
  15. </view>
  16. </view>
  17. <view class="add-info">
  18. <view class="add-label">
  19. <text style="color: #ff4544">*</text>手机号码</view>
  20. <view class="add-input">
  21. <input v-model="phone" type="number" placeholder="请填写手机号码" placeholder-style ="font-size: 20rpx;color: #cdcdcd" />
  22. </view>
  23. </view>
  24. <view class="add-info">
  25. <view class="add-label">
  26. <text style="color: #ff4544">*</text>微信号
  27. </view>
  28. <view class="add-input">
  29. <input v-model="wechat_num" placeholder="微信号" placeholder-style="font-size: 20rpx;color: #cdcdcd" />
  30. </view>
  31. </view>
  32. <view class="add-info">
  33. <view class="add-label">
  34. <text style="color: #ff4544">*</text>微信二维码
  35. </view>
  36. <view @click="uploadQRode" class="qr-code">
  37. <block v-if="!wechat_qrcode"><image :src="root+'/web/statics/img/app/common/upload.png'"></image></block>
  38. <block v-else><image :src="wechat_qrcode"></image></block>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="submit">
  43. <view @click="subscribe">
  44. <button :style="{'background-color':`${custom_setting.apply.apply_btn_background}`,'border-radius':`${custom_setting.apply.apply_btn_round}`,'color':`${custom_setting.apply.apply_btn_color}`}">保存</button>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 特权 -->
  49. <view class="other">
  50. <image @load="imageLoad" :style="{'height':`${height}rpx`}" class="end-img" :src="custom_setting.apply.apply_end_pic"></image>
  51. </view>
  52. </view>
  53. </app-layout>
  54. </template>
  55. <script>
  56. import { mapState } from "vuex";
  57. import AppDiyForm from "../../../components/page-component/app-diy-form/app-diy-form";
  58. import uploadFile from "../../../core/upload";
  59. export default {
  60. data() {
  61. return {
  62. status: null,
  63. mallName: '',
  64. name: '',
  65. phone: '',
  66. parent_name: '',
  67. height: 0,
  68. form: {},
  69. template_message: [],
  70. read: false,
  71. protocol: false,
  72. wechat_num: '',
  73. wechat_qrcode: '',
  74. root:''
  75. }
  76. },
  77. computed: {
  78. ...mapState({
  79. mall: state => state.mallConfig.mall,
  80. custom_setting: state => state.mallConfig.share_setting_custom,
  81. share_setting: state => state.mallConfig.share_setting,
  82. })
  83. },
  84. components: {
  85. AppDiyForm
  86. },
  87. methods: {
  88. handleFormInput(data) {
  89. const result = [];
  90. for (let i in data) {
  91. result[i] = {
  92. key: data[i].key,
  93. label: data[i].name,
  94. value: data[i].value,
  95. required: data[i].is_required,
  96. };
  97. }
  98. this.form = result;
  99. },
  100. toRead() {
  101. this.read = !this.read
  102. },
  103. imageLoad: function (e) {
  104. var $width = e.detail.width; //获取图片真实宽度
  105. var $height = e.detail.height; //获取图片真实高度
  106. this.height = $height * (702 / $width)
  107. },
  108. subscribe() {
  109. let that = this;
  110. if (!that.name) {
  111. uni.showToast({
  112. title: '请输入真实姓名',
  113. icon: 'none',
  114. duration: 1000
  115. });
  116. } else if (!that.phone) {
  117. uni.showToast({
  118. title: '请输入手机号码',
  119. icon: 'none',
  120. duration: 1000
  121. });
  122. } else if (!(/0?(1)[0-9]{10}/.test(that.phone))) {
  123. uni.showToast({
  124. title: '请输入正确的手机号码',
  125. icon: 'none',
  126. duration: 1000
  127. });
  128. }else if (!that.wechat_num) {
  129. uni.showToast({
  130. title: '请输入微信号',
  131. icon: 'none',
  132. duration: 1000
  133. });
  134. } else if (!that.wechat_qrcode) {
  135. uni.showToast({
  136. title: '请上传微信二维码',
  137. icon: 'none',
  138. duration: 1000
  139. });
  140. } else {
  141. // let template_message = [this.template_message]
  142. this.$subscribe(this.template_message).then(res => {
  143. this.submit();
  144. }).catch(res => {
  145. this.submit();
  146. });
  147. }
  148. },
  149. submit() {
  150. let that = this;
  151. uni.showLoading({
  152. title: '提交中...'
  153. });
  154. let para = {
  155. name: that.name,
  156. mobile: that.phone,
  157. wechat_num: that.wechat_num,
  158. wechat_qrcode: that.wechat_qrcode,
  159. }
  160. if(that.share_setting.form_status == 1) {
  161. para.form = JSON.stringify(that.form)
  162. }
  163. that.$request({
  164. url: that.$api.share.edit,
  165. data: para,
  166. method: 'post'
  167. }).then(response => {
  168. that.$store.dispatch('mallConfig/actionResetConfig');
  169. that.$hideLoading();
  170. if (response.code == 0) {
  171. uni.showToast({
  172. title: response.msg,
  173. duration: 1000
  174. });
  175. setTimeout(function() {
  176. uni.navigateBack({
  177. delta: 1
  178. })
  179. }, 500)
  180. } else {
  181. if(that.share_setting.form_status == 0 && response.msg == '请填写表单') {
  182. uni.showToast({
  183. title: '申请条件有所变化,请重新填写',
  184. icon: 'none',
  185. duration: 1000
  186. });
  187. }else {
  188. uni.showToast({
  189. title: response.msg,
  190. icon: 'none',
  191. duration: 1000
  192. });
  193. }
  194. }
  195. }).catch(e => {
  196. that.$hideLoading();
  197. uni.showToast({
  198. title: response,
  199. icon: 'none',
  200. duration: 1000
  201. });
  202. })
  203. },
  204. uploadQRode(){
  205. let _this = this;
  206. uni.chooseImage({
  207. count: 1,
  208. sizeType: ['original', 'compressed'],
  209. sourceType: ['album', 'camera'],
  210. success(res) {
  211. uni.uploadFile({
  212. url: _this.$api.upload.file,
  213. filePath: res.tempFilePaths[0],
  214. name: 'file',
  215. success(response) {
  216. _this.wechat_qrcode = JSON.parse(response.data).data.url;
  217. }
  218. });
  219. }
  220. });
  221. }
  222. },
  223. onLoad(options) {
  224. let that = this;
  225. that.root = this.$siteInfo.root;
  226. this.$showLoading({
  227. type: 'global',
  228. text: '加载中...'
  229. });
  230. if (options.template_message != null) {
  231. that.template_message = JSON.parse(options.template_message)
  232. }
  233. uni.setNavigationBarTitle({
  234. title: '编辑资料'
  235. });
  236. let _this = this;
  237. this.$request({
  238. url: this.$api.share.share_info,
  239. }).then(response => {
  240. this.$hideLoading();
  241. if (response.code === 0) {
  242. _this.name = response.data.name;
  243. _this.phone = response.data.mobile;
  244. _this.wechat_num = response.data.wechat_num;
  245. _this.wechat_qrcode = response.data.wechat_qrcode;
  246. }
  247. })
  248. },
  249. onShow() {
  250. this.$store.dispatch('mallConfig/actionResetConfig');
  251. }
  252. }
  253. </script>
  254. <style scoped lang="scss">
  255. .add-bg {
  256. height: #{300rpx};
  257. width: 100%;
  258. display: block;
  259. margin-bottom: #{20rpx};
  260. background-color: #f7f7f7;
  261. }
  262. .add-form {
  263. padding: 0 #{24rpx};
  264. font-size: #{30rpx};
  265. color: #353535;
  266. .add-default {
  267. background-color: #fff;
  268. border-radius: #{16rpx};
  269. padding: 0 #{10rpx} #{35rpx};
  270. margin-bottom: #{20rpx};
  271. &.add-diy-form {
  272. padding-bottom: 0;
  273. padding: #{10rpx} #{24rpx};
  274. .add-info {
  275. border-bottom: 0;
  276. padding: #{24rpx} 0;
  277. }
  278. }
  279. .add-info {
  280. width: 100%;
  281. padding: #{10rpx} #{24rpx};
  282. border-bottom: #{1rpx} solid #e2e2e2;
  283. .red-background {
  284. background-color: #ff4544;
  285. }
  286. .add-label {
  287. height: #{45rpx};
  288. line-height: #{45rpx};
  289. font-size: #{28rpx};
  290. }
  291. .add-input {
  292. height: #{75rpx};
  293. input {
  294. height: #{65rpx};
  295. padding-top: #{5rpx};
  296. }
  297. }
  298. &.share-name {
  299. height: #{90rpx};
  300. line-height: #{90rpx};
  301. padding: 0 #{10rpx};
  302. .mall-name {
  303. max-width: #{300rpx};
  304. color: #ff4544;
  305. }
  306. }
  307. .share-user {
  308. color: #666;
  309. height: #{75rpx};
  310. line-height: #{75rpx};
  311. >text {
  312. color: #ff4544;
  313. }
  314. }
  315. .read {
  316. width: #{32rpx};
  317. height: #{32rpx};
  318. float: left;
  319. margin-right: #{10rpx};
  320. image {
  321. height: 100%;
  322. width: 100%;
  323. display: block;
  324. }
  325. }
  326. }
  327. .qr-code image{
  328. width: #{200rpx};
  329. height: #{200rpx};
  330. }
  331. }
  332. }
  333. .submit {
  334. background-color: #f7f7f7;
  335. margin: 0 #{-24rpx};
  336. padding: #{24rpx};
  337. button {
  338. color: #fff;
  339. font-size: #{30rpx};
  340. font-weight: bold;
  341. height: #{80rpx};
  342. border-radius: #{40rpx};
  343. line-height: #{80rpx};
  344. }
  345. }
  346. .other {
  347. background-color: #fff;
  348. padding: 0 #{24rpx};
  349. color: #353535;
  350. font-size: #{30rpx};
  351. .end-img {
  352. width: 100%;
  353. }
  354. }
  355. .modal {
  356. position: fixed;
  357. top: 0;
  358. left: 0;
  359. right: 0;
  360. height: 100%;
  361. width: 100%;
  362. z-index: 99;
  363. background-color: rgba(0, 0, 0, 0.3);
  364. .protocol {
  365. position: relative;
  366. z-index: 99;
  367. background-color: #fff;
  368. width: 80%;
  369. border-radius: #{20rpx};
  370. margin: #{100rpx} auto;
  371. .protocol-name {
  372. height: #{100rpx};
  373. text-align: center;
  374. line-height: #{100rpx};
  375. color: #666;
  376. }
  377. .protocol-content {
  378. padding: #{10rpx} #{20rpx};
  379. height: #{720rpx};
  380. overflow: auto;
  381. color: #353535;
  382. }
  383. .read-over {
  384. text-align: center;
  385. height: #{100rpx};
  386. line-height: #{100rpx};
  387. background-color: #ff4544;
  388. color: #fff;
  389. font-size: #{30rpx};
  390. border-bottom-right-radius: #{20rpx};
  391. border-bottom-left-radius: #{20rpx};
  392. }
  393. }
  394. }
  395. </style>