leagueApplication.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="leagueApplication">
  3. <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" :title-width="400"
  4. back-icon-color="#fff" title-color="#fff"
  5. :background="background" :title="i18n('AllianceApplication')">
  6. </u-navbar>
  7. <view class="content">
  8. <view class="title">{{$t('common.Membershipapplicationinformation')}}</view>
  9. <view class="form-box">
  10. <u-form :model="form" ref="uForm" label-position="top">
  11. <u-form-item>
  12. <u-checkbox-group :wrap="true" @change="leagueNameValue">
  13. <u-checkbox v-model="item.checked" :name="item.baseEntityId"
  14. v-for="(item,index) in baseLeagueInfos" :key="index">
  15. {{($i18n.locale=='zh'?'全球能源互联网':'World of Energy Interconnection ')+item.leagueName}}
  16. </u-checkbox>
  17. </u-checkbox-group>
  18. </u-form-item>
  19. <u-form-item :label="$i18n.locale == 'zh'? '姓名': 'Name of the contact'" prop="name" required>
  20. <u-input v-model="form.name" :placeholder="placeholder.name" />
  21. </u-form-item>
  22. <u-form-item :label="$i18n.locale == 'zh'? '单位名称': 'Name of the entity'" prop="unitName" required>
  23. <u-input v-model="form.unitName" :placeholder="placeholder.unitName" />
  24. </u-form-item>
  25. <u-form-item :label="$i18n.locale == 'zh'? '邮箱': 'E-mail'" prop="email" required>
  26. <u-input v-model="form.email" :placeholder="placeholder.email" />
  27. </u-form-item>
  28. <u-form-item :label="$i18n.locale == 'zh'? '联系电话': 'Contact phone number'" prop="tel" required>
  29. <u-input v-model="form.tel" :placeholder="placeholder.tel" />
  30. </u-form-item>
  31. </u-form>
  32. <u-button shape="circle" type="primary" class="custom-style" @click="submit">{{$t('common.submit')}}</u-button>
  33. </view>
  34. </view>
  35. <u-toast ref="uToast" />
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. background:{
  43. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  44. },
  45. backStyle:{
  46. color:'#fff'
  47. },
  48. baseLeagueInfos:[],
  49. form: {
  50. name: '',
  51. unitName: '',
  52. email: '',
  53. tel: ''
  54. },
  55. token: '',
  56. leagueBaseIdStr: [],
  57. placeholder: {
  58. name: this.$i18n.locale == 'zh'? '请输入姓名': 'Please enter the name of the contact',
  59. unitName: this.$i18n.locale == 'zh'? '请输入单位名称': 'Please enter the name of the entity',
  60. email: this.$i18n.locale == 'zh'? '请输入邮箱': 'Please enter the e-mail',
  61. tel: this.$i18n.locale == 'zh'? '请输入联系电话': 'Please enter the contact phone number'
  62. },
  63. rules: {
  64. name: [
  65. {
  66. required: true,
  67. message: this.$i18n.locale == 'zh'? '请输入姓名': 'Please enter the name of the contact',
  68. trigger: 'blur'
  69. }
  70. ],
  71. unitName: [
  72. {
  73. required: true,
  74. message: this.$i18n.locale == 'zh'? '请输入单位名称': 'Please enter the name of the entity',
  75. trigger: 'blur'
  76. }
  77. ],
  78. email: [
  79. {
  80. required: true,
  81. message: this.$i18n.locale == 'zh'? '请输入邮箱': 'Please enter the e-mail',
  82. trigger: 'blur'
  83. },
  84. {
  85. message: this.$i18n.locale == 'zh'? '邮箱格式不正确': 'Email format is not correct, please input again',
  86. type: 'email',
  87. trigger: 'blur'
  88. }
  89. ],
  90. tel: [
  91. {
  92. required: true,
  93. message: this.$i18n.locale == 'zh'? '请输入联系电话': 'Please enter the contact phone number',
  94. trigger: 'blur'
  95. },
  96. {
  97. validator: (rule, value, callback) => {
  98. return this.$u.test.mobile(value);
  99. },
  100. message: this.$i18n.locale == 'zh'? '手机号码不正确': 'The contact phone number is incorrect',
  101. trigger: 'blur'
  102. }
  103. ]
  104. }
  105. }
  106. },
  107. onLoad() {
  108. this.getIntaData();
  109. this.getUser();
  110. },
  111. onReady() {
  112. this.$refs.uForm.setRules(this.rules);
  113. },
  114. methods: {
  115. i18n (data) {
  116. return this.$t('common.'+data);
  117. },
  118. async getIntaData() {
  119. const res = await this.$myRequest({
  120. url: '/project/baseLeagueInfos/getBaseLeagues',
  121. data: {
  122. language: this.$i18n.locale.toUpperCase()
  123. }
  124. });
  125. // console.log(res);
  126. this.baseLeagueInfos = res.data.baseLeagueInfos;
  127. },
  128. async getUser() {
  129. let user = uni.getStorageSync('user');
  130. let token = uni.getStorageSync('Auth-Token');
  131. console.log(user!=undefined && token!=undefined);
  132. if (!token && !user) {
  133. uni.setStorageSync('pathReminder', '/pages/service/membership/leagueApplication')
  134. uni.showToast({
  135. title: '请先登录',
  136. icon: 'none'
  137. })
  138. setTimeout(() => {
  139. uni.navigateTo({
  140. url: "/pages/public/login?back=1&language=zh"
  141. })
  142. }, 1000)
  143. }
  144. },
  145. leagueNameValue(value) {
  146. this.leagueBaseIdStr = value;
  147. },
  148. async submit() {
  149. const res = await this.$myRequest({
  150. url: '/project/baseLeagueApplys/getSelfAllianceApply'
  151. });
  152. this.$refs.uForm.validate(valid => {
  153. if (valid) {
  154. if(this.leagueBaseIdStr.length == 0) {
  155. this.$refs.uToast.show({
  156. title: this.$i18n.locale == 'zh'?'请选择专业联盟!':'Please select professional alliance!',
  157. });
  158. return;
  159. }
  160. let leagueApply = res.data.baseLeagueApplyList;
  161. // console.log(leagueApply);
  162. if(leagueApply) {
  163. this.$refs.uToast.show({
  164. title: this.$i18n.locale == 'zh'?'您已申请!':'You have applied!',
  165. type: 'warning'
  166. });
  167. return;
  168. }else {
  169. this.getToken();
  170. }
  171. } else {
  172. console.log('验证失败');
  173. }
  174. });
  175. },
  176. async commitMemberApply() {
  177. const that = this;
  178. let leagueBaseNameStr = [];
  179. this.baseLeagueInfos.forEach(item1 => {
  180. this.leagueBaseIdStr.forEach(item2 => {
  181. if(item1.baseEntityId == item2) {
  182. leagueBaseNameStr.push(item1.leagueName);
  183. }
  184. })
  185. });
  186. const res = await this.$myRequest({
  187. url: '/project/baseLeagueApplys/appCommitLeagueMemberApply',
  188. method: 'POST',
  189. data: {
  190. // type:'formData',
  191. contactsName: this.form.name,
  192. unitZhName: this.form.unitName,
  193. mobilePhone: this.form.tel,
  194. telephoneNumber: this.form.tel,
  195. email: this.form.email,
  196. language: this.$i18n.locale.toUpperCase(),
  197. leagueBaseIdStr: this.leagueBaseIdStr.join(),
  198. leagueBaseNameStr: leagueBaseNameStr.join(),
  199. token: this.token
  200. }
  201. });
  202. // console.log(res);
  203. if(res.status == 200) {
  204. uni.navigateTo({
  205. url: '/pages/service/membership/successful?value=league&key='+res.data
  206. })
  207. }else {
  208. this.$refs.uToast.show({
  209. title: this.$i18n.locale == 'zh'?'申请失败!':'Application failed!',
  210. type: 'error'
  211. });
  212. }
  213. },
  214. async getToken() {
  215. const res = await this.$myRequest({
  216. url: '/sys/token'
  217. });
  218. // console.log(res);
  219. this.token = res.data;
  220. this.commitMemberApply();
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .leagueApplication {
  227. .content {
  228. margin-top: 20upx;
  229. background-color: #FFFFFF;
  230. padding: 30upx;
  231. height: calc(100vh - 20upx - 44px - var(--status-bar-height));
  232. }
  233. .title {
  234. color: #1777FE;
  235. font-size: 32upx;
  236. }
  237. .custom-style {
  238. width: 100%;
  239. height: 80upx;
  240. margin-top: 60upx;
  241. }
  242. }
  243. </style>