apply.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  110. //勾选协议
  111. function onChange() {
  112. state.isAgree = !state.isAgree;
  113. }
  114. const submitText = computed(() => {
  115. if (state.status === 'normal') return '修改信息';
  116. if (state.status === 'needinfo') return '提交审核';
  117. if (state.status === 'reject') return '重新提交';
  118. return '';
  119. });
  120. async function getAgentForm() {
  121. const { error, data } = await sheep.$api.commission.form();
  122. state.error = error;
  123. if (error === 0) {
  124. state.status = data.status;
  125. state.background = data.background;
  126. state.formList = data.form;
  127. state.applyInfo = data.applyInfo;
  128. state.protocol = data.protocol;
  129. if (data.protocol.status != 1) {
  130. state.isAgree = true;
  131. }
  132. mergeFormList();
  133. }
  134. }
  135. function onImgLoad(e) {
  136. state.imgHeight = (e.detail.height / e.detail.width) * 750 - 88 - statusBarHeight;
  137. }
  138. async function submit() {
  139. if (!state.isAgree) {
  140. sheep.$helper.toast('请同意申请协议');
  141. return;
  142. }
  143. const validate = state.formList.every((item) => {
  144. if (isEmpty(item.value)) {
  145. if (item.type !== 'image') {
  146. sheep.$helper.toast(`请填写${item.name}`);
  147. } else {
  148. sheep.$helper.toast(`请上传${item.name}`);
  149. }
  150. return false;
  151. }
  152. return true;
  153. });
  154. if (!validate) {
  155. return;
  156. }
  157. const { error } = await sheep.$api.commission.apply({
  158. data: state.formList,
  159. });
  160. if (error === 0) {
  161. sheep.$router.back();
  162. }
  163. }
  164. onLoad(() => {
  165. getAgentForm();
  166. });
  167. // 初始化formData
  168. function mergeFormList() {
  169. state.formList.forEach((form) => {
  170. const apply = state.applyInfo.find(
  171. (info) => info.type === form.type && info.name === form.name,
  172. );
  173. if (typeof apply !== 'undefined') form.value = apply.value;
  174. });
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. :deep() {
  179. .uni-forms-item__label .label-text {
  180. font-size: 28rpx !important;
  181. color: #333333 !important;
  182. line-height: normal !important;
  183. }
  184. .file-picker__progress {
  185. height: 0 !important;
  186. }
  187. .uni-list-item__content-title {
  188. font-size: 28rpx !important;
  189. color: #333333 !important;
  190. line-height: normal !important;
  191. }
  192. .uni-icons {
  193. font-size: 40rpx !important;
  194. }
  195. .is-disabled {
  196. color: #333333;
  197. }
  198. }
  199. .distribution-apply-wrap {
  200. // height: 100vh;
  201. // width: 100vw;
  202. // position: absolute;
  203. // left: 0;
  204. // top: 0;
  205. // background-color: #fff;
  206. // overflow-y: auto;
  207. .submit-btn {
  208. width: 690px;
  209. height: 86rpx;
  210. border-radius: 43rpx;
  211. }
  212. .apply-header {
  213. position: absolute;
  214. left: 0;
  215. top: 0;
  216. }
  217. .header-box {
  218. width: 100%;
  219. position: relative;
  220. .bg-img {
  221. width: 750rpx;
  222. }
  223. .heaer-title {
  224. position: absolute;
  225. left: 30rpx;
  226. top: 50%;
  227. transform: translateY(-50%);
  228. font-size: 50rpx;
  229. font-weight: bold;
  230. color: #ffffff;
  231. z-index: 11;
  232. &::before {
  233. content: '';
  234. width: 51rpx;
  235. height: 8rpx;
  236. background: #ffffff;
  237. border-radius: 4rpx;
  238. position: absolute;
  239. z-index: 12;
  240. bottom: -20rpx;
  241. }
  242. }
  243. }
  244. .apply-box {
  245. padding: 0 40rpx;
  246. .item-box {
  247. border-bottom: 2rpx solid #eee;
  248. }
  249. }
  250. }
  251. .agreement-text {
  252. font-size: 24rpx;
  253. color: #c4c4c4;
  254. line-height: normal;
  255. .tcp-text {
  256. color: var(--ui-BG-Main);
  257. }
  258. }
  259. .card-image {
  260. width: 140rpx;
  261. height: 140rpx;
  262. border-radius: 50%;
  263. }
  264. </style>