add.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <app-layout>
  3. <view class="page">
  4. <!-- 申请页面背景图片以及待审核页面背景图片 -->
  5. <image :src="custom_setting.apply.apply_head_pic" class="add-bg"></image>
  6. <!-- 未在申请分销商 -->
  7. <view>
  8. <view class="add-form">
  9. <view class="add-info">
  10. <view class="share-name">欢迎加入
  11. <text :class="[`${theme}-color`]">{{mall.name}}</text>
  12. </view>,请填写申请信息</view>
  13. <view class="add-info">
  14. <view class="add-label">邀请人</view>
  15. <view class="share-user">
  16. <text :class="[`${theme}-color`]">{{parent_name}}</text>(请核对)</view>
  17. </view>
  18. <view>
  19. <view class="add-info">
  20. <view class="add-label">姓名</view>
  21. <view class="add-input">
  22. <input v-model="name" placeholder="请填写真实姓名"></input>
  23. </view>
  24. </view>
  25. <view class="add-info">
  26. <view class="add-label">手机号码</view>
  27. <view class="add-input">
  28. <input v-model="phone" type="number" placeholder="请填写手机号码"></input>
  29. </view>
  30. </view>
  31. <view class="add-info" style="font-size:13px;">
  32. <view class="read" @click="toRead">
  33. <image src="/static/image/icon/icon-uncheck.png" v-if="read == false"></image>
  34. <image :class="[`${theme}-background`]" src="/static/image/icon/icon-checkbox-checked.png" v-else></image>
  35. </view>
  36. 我已经阅读并了解
  37. <text style="color:#014c8c" @click="protocol = true">【{{custom_setting.apply.share_apply_pact.name ? custom_setting.apply.share_apply_pact.name : custom_setting.apply.share_apply_pact.default}}】</text>
  38. </view>
  39. <view class="submit">
  40. <view @click="subscribe">
  41. <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}`}">{{custom_setting.apply.apply_btn_title ? custom_setting.apply.apply_btn_title : '申请成为分销商'}}</button>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 特权 -->
  47. <view class="other">
  48. <image @load="imageLoad" :style="{'height':`${height}rpx`}" class="end-img" :src="custom_setting.apply.apply_end_pic"></image>
  49. </view>
  50. <!-- 分销协议(modal模式) -->
  51. <view class="modal" v-if="protocol">
  52. <view class="protocol">
  53. <view class="protocol-name">{{custom_setting.apply.share_apply_pact.name ? custom_setting.apply.share_apply_pact.name : custom_setting.apply.share_apply_pact.default}}</view>
  54. <view class="protocol-content">
  55. <text>{{share_setting.agree}}</text>
  56. </view>
  57. <view @click="protocol=false;read=true">
  58. <view class="read-over">我已阅读</view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </app-layout>
  65. </template>
  66. <script>
  67. import { mapState } from "vuex";
  68. export default {
  69. data() {
  70. return {
  71. status: null,
  72. mallName: '',
  73. name: '',
  74. phone: '',
  75. parent_name: '总店',
  76. height: 0,
  77. template_message: [],
  78. read: false,
  79. protocol: false
  80. }
  81. },
  82. computed: {
  83. ...mapState({
  84. theme: state => state.mallConfig.theme,
  85. mall: state => state.mallConfig.mall,
  86. custom_setting: state => state.mallConfig.share_setting_custom,
  87. share_setting: state => state.mallConfig.share_setting,
  88. })
  89. },
  90. methods: {
  91. toRead() {
  92. this.read = !this.read
  93. },
  94. imageLoad: function (e) {
  95. var $width = e.detail.width; //获取图片真实宽度
  96. var $height = e.detail.height; //获取图片真实高度
  97. this.height = $height * (702 / $width)
  98. },
  99. subscribe() {
  100. let that = this;
  101. let read = 0;
  102. if (this.read == true) {
  103. read = 1;
  104. if (!that.name) {
  105. uni.showToast({
  106. title: '请输入真实姓名',
  107. icon: 'none',
  108. duration: 1000
  109. });
  110. } else if (!that.phone) {
  111. uni.showToast({
  112. title: '请输入手机号码',
  113. icon: 'none',
  114. duration: 1000
  115. });
  116. } else if (!(/0?(1)[0-9]{10}/.test(that.phone))) {
  117. uni.showToast({
  118. title: '请输入正确的手机号码',
  119. icon: 'none',
  120. duration: 1000
  121. });
  122. } else {
  123. // let template_message = [this.template_message]
  124. this.$subscribe(this.template_message).then(res => {
  125. this.submit(read);
  126. }).catch(res => {
  127. this.submit(read);
  128. });
  129. }
  130. } else {
  131. uni.showToast({
  132. title: '请先查看分销协议并同意',
  133. icon: 'none',
  134. duration: 1000
  135. });
  136. }
  137. },
  138. submit(read) {
  139. let that = this;
  140. uni.showLoading({
  141. title: '加载中...'
  142. });
  143. that.$request({
  144. url: that.$api.share.apply,
  145. data: {
  146. name: that.name,
  147. mobile: that.phone,
  148. agree: read
  149. },
  150. method: 'post'
  151. }).then(response => {
  152. that.$hideLoading();
  153. if (response.code == 0) {
  154. uni.showToast({
  155. title: response.msg,
  156. duration: 1000
  157. });
  158. setTimeout(function() {
  159. uni.navigateBack({
  160. delta: 1
  161. })
  162. }, 500)
  163. } else {
  164. uni.showToast({
  165. title: response.msg,
  166. icon: 'none',
  167. duration: 1000
  168. });
  169. }
  170. }).catch(e => {
  171. that.$hideLoading();
  172. uni.showToast({
  173. title: response,
  174. icon: 'none',
  175. duration: 1000
  176. });
  177. })
  178. }
  179. },
  180. onLoad(options) {
  181. let that = this;
  182. if (options.parent_name != null) {
  183. that.parent_name = options.parent_name
  184. }
  185. if (options.template_message != null) {
  186. that.template_message = JSON.parse(options.template_message)
  187. }
  188. uni.setNavigationBarTitle({
  189. title: this.custom_setting.apply.share_apply.name ? this.custom_setting.apply.share_apply.name : this.custom_setting.apply.share_apply.default
  190. });
  191. }
  192. }
  193. </script>
  194. <style scoped lang="scss">
  195. .page {
  196. position: absolute;
  197. top: 0;
  198. left: 0;
  199. height: 100%;
  200. width: 100%;
  201. background-color: #fff;
  202. }
  203. .add-bg {
  204. height: #{300rpx};
  205. width: 100%;
  206. display: block;
  207. margin-bottom: #{20rpx};
  208. background-color: #f7f7f7;
  209. }
  210. .add-form {
  211. background-color: #fff;
  212. padding: 0 #{24rpx};
  213. font-size: #{30rpx};
  214. color: #353535;
  215. }
  216. .add-info {
  217. height: #{100rpx};
  218. line-height: #{100rpx};
  219. width: 100%;
  220. border-bottom: #{1rpx} solid #e2e2e2;
  221. }
  222. .add-info .add-label {
  223. float: left;
  224. width: #{180rpx};
  225. }
  226. .add-info .share-name {
  227. max-width: #{400rpx};
  228. height: #{100rpx};
  229. overflow: hidden;
  230. float: left;
  231. }
  232. .share-user {
  233. color: #666;
  234. }
  235. .add-input {
  236. height: #{100rpx};
  237. }
  238. .add-input input {
  239. height: #{75rpx};
  240. padding-top: #{25rpx};
  241. }
  242. .read {
  243. width: #{32rpx};
  244. height: #{32rpx};
  245. float: left;
  246. margin-top: #{34rpx};
  247. margin-right: #{10rpx};
  248. }
  249. .read image {
  250. height: 100%;
  251. width: 100%;
  252. display: block;
  253. }
  254. .submit {
  255. background-color: #f7f7f7;
  256. margin: 0 #{-24rpx};
  257. padding: #{24rpx};
  258. }
  259. .submit button {
  260. color: #fff;
  261. font-size: #{30rpx};
  262. font-weight: bold;
  263. height: #{80rpx};
  264. border-radius: #{40rpx};
  265. line-height: #{80rpx};
  266. }
  267. .other {
  268. background-color: #fff;
  269. padding: 0 #{24rpx};
  270. border-bottom: #{1rpx} solid #e2e2e2;
  271. border-top: #{1rpx} solid #e2e2e2;
  272. color: #353535;
  273. font-size: #{30rpx};
  274. }
  275. .end-img {
  276. width: 100%;
  277. }
  278. .caption {
  279. padding: #{24rpx} 0;
  280. }
  281. .modal {
  282. position: fixed;
  283. top: 0;
  284. left: 0;
  285. right: 0;
  286. height: 100%;
  287. width: 100%;
  288. z-index: 99;
  289. background-color: rgba(0, 0, 0, 0.3);
  290. }
  291. .protocol {
  292. position: relative;
  293. z-index: 99;
  294. background-color: #fff;
  295. width: 80%;
  296. border-radius: #{20rpx};
  297. margin: #{100rpx} auto;
  298. }
  299. .protocol-name {
  300. height: #{100rpx};
  301. text-align: center;
  302. line-height: #{100rpx};
  303. color: #666;
  304. }
  305. .protocol-content {
  306. padding: #{10rpx} #{20rpx};
  307. height: #{720rpx};
  308. overflow: auto;
  309. color: #353535;
  310. }
  311. .read-over {
  312. text-align: center;
  313. height: #{100rpx};
  314. line-height: #{100rpx};
  315. background-color: #ff4544;
  316. color: #fff;
  317. font-size: #{30rpx};
  318. border-bottom-right-radius: #{20rpx};
  319. border-bottom-left-radius: #{20rpx};
  320. }
  321. .thx {
  322. padding: #{100rpx};
  323. text-align: center;
  324. color: #666;
  325. font-size: #{30rpx};
  326. }
  327. .thx image {
  328. height: #{80rpx};
  329. width: #{80rpx};
  330. margin-bottom: #{50rpx};
  331. }
  332. </style>