apply.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <!-- 申请分销商 -->
  2. <template>
  3. <s-layout title="申请分销商" class="apply-wrap" navbar="inner">
  4. <s-empty
  5. v-if="state.error === 1"
  6. paddingTop="0"
  7. icon="/static/comment-empty.png"
  8. text="未开启分销商申请"
  9. ></s-empty>
  10. <view v-if="state.error === 0" class="distribution-apply-wrap">
  11. <view class="apply-header">
  12. <view class="header-box ss-flex">
  13. <image
  14. class="bg-img"
  15. :src="sheep.$url.cdn(state.background)"
  16. mode="widthFix"
  17. @load="onImgLoad"
  18. ></image>
  19. <view class="heaer-title">申请分销商</view>
  20. </view>
  21. </view>
  22. <view class="apply-box bg-white" :style="{ marginTop: state.imgHeight + 'rpx' }">
  23. <uni-forms
  24. label-width="200"
  25. :model="state.model"
  26. :rules="state.rules"
  27. border
  28. class="form-box"
  29. >
  30. <view class="item-box">
  31. <uni-forms-item
  32. v-for="(item, index) in state.formList"
  33. :key="index"
  34. :label="item.name"
  35. :required="true"
  36. :label-position="item.type == 'image' ? 'top' : 'left'"
  37. >
  38. <uni-easyinput
  39. v-if="item.type !== 'image'"
  40. :inputBorder="false"
  41. :type="item.type"
  42. :styles="{ disableColor: '#fff' }"
  43. placeholderStyle="color:#BBBBBB;font-size:28rpx;line-height:normal"
  44. v-model="item.value"
  45. :placeholder="`请填写${item.name}`"
  46. />
  47. <s-uploader
  48. v-if="item.type === 'image'"
  49. v-model="item.aaa"
  50. v-model:url="item.value"
  51. fileMediatype="image"
  52. limit="1"
  53. mode="grid"
  54. :imageStyles="{ width: '168rpx', height: '168rpx' }"
  55. class="file-picker"
  56. />
  57. </uni-forms-item>
  58. </view>
  59. </uni-forms>
  60. <label class="ss-flex ss-m-t-20" v-if="state.protocol?.status == 1" @tap="onChange">
  61. <radio
  62. :checked="state.isAgree"
  63. color="var(--ui-BG-Main)"
  64. style="transform: scale(0.6)"
  65. @tap.stop="onChange"
  66. />
  67. <view class="agreement-text ss-flex">
  68. <view class="ss-m-r-4">勾选代表同意</view>
  69. <view
  70. class="tcp-text"
  71. @tap.stop="
  72. sheep.$router.go('/pages/public/richtext', {
  73. id: state.protocol.id,
  74. title: state.protocol.title,
  75. })
  76. "
  77. >
  78. 《{{ state.protocol.title }}》
  79. </view>
  80. </view>
  81. </label>
  82. <su-fixed bottom placeholder>
  83. <view class="submit-box ss-flex ss-row-center ss-p-30">
  84. <button class="submit-btn ss-reset-button ui-BG-Main ui-Shadow-Main" @tap="submit">
  85. {{ submitText }}
  86. </button>
  87. </view>
  88. </su-fixed>
  89. </view>
  90. </view>
  91. </s-layout>
  92. </template>
  93. <script setup>
  94. import sheep from '@/sheep';
  95. import { onLoad } from '@dcloudio/uni-app';
  96. import { computed, reactive } from 'vue';
  97. import { isEmpty } from 'lodash';
  98. const state = reactive({
  99. error: -1,
  100. status: '-',
  101. config: {},
  102. isAgree: false,
  103. formList: [],
  104. protocol: {},
  105. applyInfo: [],
  106. background: '',
  107. imgHeight: 400,
  108. });
  109. //勾选协议
  110. function onChange() {
  111. state.isAgree = !state.isAgree;
  112. }
  113. const submitText = computed(() => {
  114. if (state.status === 'normal') return '修改信息';
  115. if (state.status === 'needinfo') return '提交审核';
  116. if (state.status === 'reject') return '重新提交';
  117. return '';
  118. });
  119. async function getAgentForm() {
  120. const { error, data } = await sheep.$api.commission.form();
  121. state.error = error;
  122. if (error === 0) {
  123. state.status = data.status;
  124. state.background = data.background;
  125. state.formList = data.form;
  126. state.applyInfo = data.applyInfo;
  127. state.protocol = data.protocol;
  128. if (data.protocol.status != 1) {
  129. state.isAgree = true;
  130. }
  131. mergeFormList();
  132. }
  133. }
  134. function onImgLoad(e) {
  135. state.imgHeight = (e.detail.height / e.detail.width) * 750 - 88;
  136. }
  137. async function submit() {
  138. if (!state.isAgree) {
  139. sheep.$helper.toast('请同意申请协议');
  140. return;
  141. }
  142. const validate = state.formList.every((item) => {
  143. if (isEmpty(item.value)) {
  144. if (item.type !== 'image') {
  145. sheep.$helper.toast(`请填写${item.name}`);
  146. } else {
  147. sheep.$helper.toast(`请上传${item.name}`);
  148. }
  149. return false;
  150. }
  151. return true;
  152. });
  153. if (!validate) {
  154. return;
  155. }
  156. const { error } = await sheep.$api.commission.apply({
  157. data: state.formList,
  158. });
  159. if (error === 0) {
  160. sheep.$router.back();
  161. }
  162. }
  163. onLoad(() => {
  164. getAgentForm();
  165. });
  166. // 初始化formData
  167. function mergeFormList() {
  168. state.formList.forEach((form) => {
  169. const apply = state.applyInfo.find(
  170. (info) => info.type === form.type && info.name === form.name,
  171. );
  172. if (typeof apply !== 'undefined') form.value = apply.value;
  173. });
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. :deep() {
  178. .uni-forms-item__label .label-text {
  179. font-size: 28rpx !important;
  180. color: #333333 !important;
  181. line-height: normal !important;
  182. }
  183. .file-picker__progress {
  184. height: 0 !important;
  185. }
  186. .uni-list-item__content-title {
  187. font-size: 28rpx !important;
  188. color: #333333 !important;
  189. line-height: normal !important;
  190. }
  191. .uni-icons {
  192. font-size: 40rpx !important;
  193. }
  194. .is-disabled {
  195. color: #333333;
  196. }
  197. }
  198. .distribution-apply-wrap {
  199. // height: 100vh;
  200. // width: 100vw;
  201. // position: absolute;
  202. // left: 0;
  203. // top: 0;
  204. // background-color: #fff;
  205. // overflow-y: auto;
  206. .submit-btn {
  207. width: 690px;
  208. height: 86rpx;
  209. border-radius: 43rpx;
  210. }
  211. .apply-header {
  212. position: absolute;
  213. left: 0;
  214. top: 0;
  215. }
  216. .header-box {
  217. width: 100%;
  218. position: relative;
  219. .bg-img {
  220. width: 750rpx;
  221. }
  222. .heaer-title {
  223. position: absolute;
  224. left: 30rpx;
  225. top: 50%;
  226. transform: translateY(-50%);
  227. font-size: 50rpx;
  228. font-weight: bold;
  229. color: #ffffff;
  230. z-index: 11;
  231. &::before {
  232. content: '';
  233. width: 51rpx;
  234. height: 8rpx;
  235. background: #ffffff;
  236. border-radius: 4rpx;
  237. position: absolute;
  238. z-index: 12;
  239. bottom: -20rpx;
  240. }
  241. }
  242. }
  243. .apply-box {
  244. padding: 0 40rpx;
  245. .item-box {
  246. border-bottom: 2rpx solid #eee;
  247. }
  248. }
  249. }
  250. .agreement-text {
  251. font-size: 24rpx;
  252. color: #c4c4c4;
  253. line-height: normal;
  254. .tcp-text {
  255. color: var(--ui-BG-Main);
  256. }
  257. }
  258. .card-image {
  259. width: 140rpx;
  260. height: 140rpx;
  261. border-radius: 50%;
  262. }
  263. </style>