use.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /**
  2. *@des 用户模块接口
  3. *@author zhengjinyi
  4. *@date 2020/03/19 14:56:57
  5. *@param registerByPass
  6. */
  7. import request from '@/common/config/caimeiApi.js'
  8. import $reg from '@/common/config/common.js'
  9. /**
  10. *机构注册第一步校验
  11. */
  12. export function organizationVerifyRegisterFirst(params) {
  13. return new Promise(function(resolve,reject) {
  14. if( params.email == ''){
  15. uni.showToast({title: '请输入邮箱地址',duration: 2000,mask:true, icon:'none'})
  16. return
  17. }
  18. if(!$reg.isEmail(params.email)){
  19. uni.showToast({title: '请输入正确的邮箱地址',duration: 2000,mask:true,icon:'none'})
  20. return
  21. }
  22. if( params.mailboxCode == ''){
  23. uni.showToast({title: '请输入邮箱验证码',duration: 2000,mask:true,icon:'none'})
  24. return
  25. }
  26. if(!$reg.isEmailCode(params.mailboxCode)){
  27. uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
  28. return
  29. }
  30. if( params.password == ''){
  31. uni.showToast({title: '请输入密码',duration: 2000,mask:true,icon:'none'})
  32. return
  33. }
  34. if(!$reg.checkPwd(params.password)){
  35. uni.showToast({title: '密码必须为8-16位字母数字的组合',duration: 2000,mask:true,icon:'none'})
  36. return
  37. }
  38. if( params.passWordConfirm == ''){
  39. uni.showToast({title: '请再次确认密码',duration: 2000,mask:true,icon:'none'})
  40. return
  41. }
  42. if( params.passWordConfirm !== params.password){
  43. uni.showToast({title: '两次输入的密码不一致',duration: 2000,mask:true,icon:'none'})
  44. return
  45. }
  46. request.post('/club/verifyRegister',params,true,res => {
  47. if(res.code == '0'){
  48. resolve(res);
  49. }else{
  50. reject(res)
  51. }
  52. })
  53. });
  54. }
  55. /**
  56. *机构注册第二步校验
  57. */
  58. export function organizationVerifyRegisterTwo(params) {
  59. return new Promise(function(resolve,reject) {
  60. if( params.name == ''){
  61. uni.showToast({title: '请输入机构名称',duration: 2000,mask:true, icon:'none'})
  62. return
  63. }
  64. if( params.linkMan == ''){
  65. uni.showToast({title: '请输入联系人名称',duration: 2000,mask:true,icon:'none'})
  66. return
  67. }
  68. if( params.bindMobile == ''){
  69. uni.showToast({title: '请输入手机号',duration: 2000,mask:true,icon:'none'})
  70. return
  71. }
  72. if(!$reg.isMobile(params.bindMobile)){
  73. uni.showToast({title: '手机格式不正确',duration: 2000,mask:true,icon:'none'})
  74. return
  75. }
  76. if( params.activationCode == ''){
  77. uni.showToast({title: '请输入手机验证码',duration: 2000,mask:true,icon:'none'})
  78. return
  79. }
  80. if(!$reg.isMobileCode(params.activationCode)){
  81. uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
  82. return
  83. }
  84. request.post('/club/verifyRegister',params,true,res => {
  85. if(res.code == '0'){
  86. resolve(res);
  87. }else{
  88. reject(res)
  89. }
  90. })
  91. });
  92. }
  93. /**
  94. *机构注册提交审核
  95. */
  96. export function organizationRegister(params) {
  97. if(params.isAgreed!=1){
  98. uni.showToast({title: '请勾选协议',duration: 2000,mask:true,icon:'none'})
  99. return
  100. }
  101. return new Promise(function(resolve,reject) {
  102. request.post('/user/club/clubRegister',params,true, res => {
  103. if(res.code == '0'){
  104. resolve(res)
  105. }else{
  106. reject(res)
  107. }
  108. })
  109. })
  110. }
  111. /**
  112. *机构修改申请信息
  113. */
  114. export function organizationUpdateModifyInfo(params) {
  115. return new Promise(function(resolve,reject) {
  116. request.get('/user/club/applicationData',params, res => {
  117. if(res.code == '0'){
  118. resolve(res)
  119. }else{
  120. reject(res)
  121. }
  122. })
  123. })
  124. }
  125. /**
  126. *机构提交修改申请信息
  127. */
  128. export function organizationModifyUpdate(params) {
  129. return new Promise(function(resolve,reject) {
  130. request.post('/user/club/updateCompanyInfo',params,true,res => {
  131. if(res.code == '0'){
  132. resolve(res)
  133. }else{
  134. reject(res)
  135. }
  136. })
  137. })
  138. }
  139. /**
  140. *保存机构修改信息
  141. */
  142. export function organizationUpdate(params) {
  143. return new Promise(function(resolve,reject) {
  144. request.post('/operation/modifiedData',params,true,res => {
  145. if(res.code == '0'){
  146. resolve(res)
  147. }else{
  148. reject(res)
  149. }
  150. })
  151. })
  152. }
  153. /**
  154. *机构登录
  155. * @param mobileOrEmail 邮箱或手机
  156. * @param password 密码
  157. * @param source 来源 PC与小程序传:'www'crm就传'crm'
  158. */
  159. export function organizationLogin(params) {
  160. return new Promise(function(resolve,reject) {
  161. if( params.mobileOrEmail == ''){
  162. uni.showToast({title: '请输入账户名',duration: 2000,mask:true, icon:'none'})
  163. return
  164. }
  165. if( params.password == ''){
  166. uni.showToast({title: '请输入密码',duration: 2000,mask:true,icon:'none'})
  167. return
  168. }
  169. request.post('/user/login',params,true, res => {
  170. resolve(res)
  171. })
  172. })
  173. }
  174. /**
  175. *绑定邮箱
  176. */
  177. export function bindingEmail(params) {
  178. return new Promise(function(resolve,reject) {
  179. if( params.email == ''){
  180. uni.showToast({title: '请输入邮箱地址',duration: 2000,mask:true, icon:'none'})
  181. return
  182. }
  183. if(!$reg.isEmail(params.email)){
  184. uni.showToast({title: '请输入正确的邮箱地址',duration: 2000,mask:true,icon:'none'})
  185. return
  186. }
  187. if( params.code == ''){
  188. uni.showToast({title: '请输入邮箱验证码',duration: 2000,mask:true,icon:'none'})
  189. return
  190. }
  191. if(!$reg.isEmailCode(params.code)){
  192. uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
  193. return
  194. }
  195. request.post('/user/binding',params,true, res => {
  196. if(res.code == '0'){
  197. resolve(res)
  198. }else{
  199. reject(res)
  200. }
  201. })
  202. })
  203. }
  204. /**
  205. *绑定微信
  206. */
  207. export function bindingWechat(params) {
  208. return new Promise(function(resolve,reject) {
  209. request.post('/club/bindingWx',params,true,res => {
  210. if(res.code == '0'){
  211. resolve(res)
  212. }else{
  213. reject(res)
  214. }
  215. })
  216. })
  217. }
  218. /**
  219. *邀请码授权登录
  220. */
  221. export function invitationCodeLogin(params) {
  222. return new Promise(function(resolve,reject) {
  223. request.post('/club/invitationCode',params,true, res => {
  224. if(res.code == '0'){
  225. resolve(res)
  226. }else{
  227. reject(res)
  228. }
  229. })
  230. })
  231. }
  232. /**
  233. *获取个人中心信息
  234. */
  235. export function personalInfo(params) {
  236. return new Promise(function(resolve,reject) {
  237. request.lodingGet('/personalCenter/myCentre',params, res => {
  238. if(res.code == '0'){
  239. resolve(res)
  240. }else{
  241. reject(res)
  242. }
  243. })
  244. })
  245. }
  246. /**
  247. *获取账户余额明细
  248. */
  249. export function accountInfo(params) {
  250. return new Promise(function(resolve,reject) {
  251. request.lodingGet('/personalCenter/touchBalance',params, res => {
  252. if(res.code == '0'){
  253. resolve(res)
  254. }else{
  255. reject(res)
  256. }
  257. })
  258. })
  259. }
  260. /**
  261. *首页初始化
  262. */
  263. export function queryHomeInfo(params) {
  264. return new Promise(function(resolve,reject) {
  265. request.get('/home/modules',{params}, res => {
  266. if(res.code == '0'){
  267. resolve(res)
  268. }else{
  269. reject(res)
  270. }
  271. })
  272. })
  273. }
  274. /**
  275. *用户状态初始化
  276. */
  277. export function userInfoLogin(params) {
  278. return new Promise(function(resolve,reject) {
  279. request.post('/club/authorization',params,false, res => {
  280. if(res.code == '0'){
  281. resolve(res)
  282. }else{
  283. reject(res)
  284. }
  285. })
  286. })
  287. }
  288. /**
  289. *手机修改密码
  290. */
  291. export function mobilePassword(params) {
  292. return new Promise(function(resolve,reject) {
  293. if( params.mobileOrEmail == ''){
  294. uni.showToast({title: '请输入手机号',duration: 2000,mask:true,icon:'none'})
  295. return
  296. }
  297. if(!$reg.isMobile(params.mobileOrEmail)){
  298. uni.showToast({title: '手机格式不正确',duration: 2000,mask:true,icon:'none'})
  299. return
  300. }
  301. if( params.activateCode == ''){
  302. uni.showToast({title: '请输入手机验证码',duration: 2000,mask:true,icon:'none'})
  303. return
  304. }
  305. if(!$reg.isMobileCode(params.activateCode)){
  306. uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
  307. return
  308. }
  309. if( params.passWord == ''){
  310. uni.showToast({title: '请输入密码',duration: 2000,mask:true,icon:'none'})
  311. return
  312. }
  313. if(!$reg.checkPwd(params.passWord)){
  314. uni.showToast({title: '密码必须为8-16位字母数字的组合',duration: 2000,mask:true,icon:'none'})
  315. return
  316. }
  317. if( params.confirmPwd == ''){
  318. uni.showToast({title: '请再次确认密码',duration: 2000,mask:true,icon:'none'})
  319. return
  320. }
  321. if( params.confirmPwd !== params.passWord){
  322. uni.showToast({title: '两次输入的密码不一致',duration: 2000,mask:true,icon:'none'})
  323. return
  324. }
  325. request.post('/user/findCompanyPwd',params, true,res => {
  326. if(res.code == '0'){
  327. resolve(res)
  328. }else{
  329. reject(res)
  330. }
  331. })
  332. })
  333. }
  334. /**
  335. *邮箱修改密码
  336. */
  337. export function emailPassword(params) {
  338. return new Promise(function(resolve,reject) {
  339. if( params.mobileOrEmail == ''){
  340. uni.showToast({title: '请输入邮箱',duration: 2000,mask:true,icon:'none'})
  341. return
  342. }
  343. if(!$reg.isEmail(params.mobileOrEmail)){
  344. uni.showToast({title: '请输入正确的邮箱地址',duration: 2000,mask:true,icon:'none'})
  345. return
  346. }
  347. if( params.activateCode == ''){
  348. uni.showToast({title: '请输入手机验证码',duration: 2000,mask:true,icon:'none'})
  349. return
  350. }
  351. if(!$reg.isEmailCode(params.activateCode)){
  352. uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
  353. return
  354. }
  355. if( params.passWord == ''){
  356. uni.showToast({title: '请输入密码',duration: 2000,mask:true,icon:'none'})
  357. return
  358. }
  359. if(!$reg.checkPwd(params.passWord)){
  360. uni.showToast({title: '密码必须为8-16位字母数字的组合',duration: 2000,mask:true,icon:'none'})
  361. return
  362. }
  363. if( params.confirmPwd == ''){
  364. uni.showToast({title: '请再次确认密码',duration: 2000,mask:true,icon:'none'})
  365. return
  366. }
  367. if( params.confirmPwd !== params.passWord){
  368. uni.showToast({title: '两次输入的密码不一致',duration: 2000,mask:true,icon:'none'})
  369. return
  370. }
  371. request.post('/user/findCompanyPwd',params,true, res => {
  372. if(res.code == '0'){
  373. resolve(res)
  374. }else{
  375. reject(res)
  376. }
  377. })
  378. })
  379. }