use.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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.linkMan1 == ''){
  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. request.post('/user/login',params,true, res => {
  162. resolve(res)
  163. })
  164. })
  165. }
  166. /**
  167. *绑定邮箱
  168. */
  169. export function bindingEmail(params) {
  170. return new Promise(function(resolve,reject) {
  171. if( params.email == ''){
  172. uni.showToast({title: '请输入邮箱地址',duration: 2000,mask:true, icon:'none'})
  173. return
  174. }
  175. if(!$reg.isEmail(params.email)){
  176. uni.showToast({title: '请输入正确的邮箱地址',duration: 2000,mask:true,icon:'none'})
  177. return
  178. }
  179. if( params.code == ''){
  180. uni.showToast({title: '请输入邮箱验证码',duration: 2000,mask:true,icon:'none'})
  181. return
  182. }
  183. if(!$reg.isEmailCode(params.code)){
  184. uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
  185. return
  186. }
  187. request.post('/user/binding',params,true, res => {
  188. if(res.code == 0){
  189. resolve(res);
  190. }else{
  191. reject(res)
  192. }
  193. })
  194. })
  195. }
  196. /**
  197. *绑定微信
  198. */
  199. export function bindingWechat(params) {
  200. return new Promise(function(resolve,reject) {
  201. request.post('/club/bindingWx',params,true,res => {
  202. if(res.code == 0){
  203. resolve(res)
  204. }else{
  205. reject(res)
  206. }
  207. })
  208. })
  209. }
  210. /**
  211. *邀请码授权登录
  212. */
  213. export function invitationCodeLogin(params) {
  214. return new Promise(function(resolve,reject) {
  215. request.post('/club/invitationCode',params,true, res => {
  216. if(res.code == 0 || res.code == 4){
  217. resolve(res)
  218. }else{
  219. reject(res)
  220. }
  221. })
  222. })
  223. }
  224. /**
  225. *获取个人中心信息
  226. */
  227. export function personalInfo(params) {
  228. return new Promise(function(resolve,reject) {
  229. request.lodingGet('/personalCenter/myCentre',params, res => {
  230. resolve(res)
  231. })
  232. })
  233. }
  234. /**
  235. *获取账户余额明细
  236. */
  237. export function accountInfo(params) {
  238. return new Promise(function(resolve,reject) {
  239. request.lodingGet('/personalCenter/touchBalance',params, res => {
  240. if(res.code == 0){
  241. resolve(res)
  242. }else{
  243. reject(res)
  244. }
  245. })
  246. })
  247. }
  248. /**
  249. *首页初始化
  250. */
  251. export function queryHomeInfo(params) {
  252. return new Promise(function(resolve,reject) {
  253. request.get('/home/modules',{params}, res => {
  254. if(res.code == 0){
  255. resolve(res)
  256. }else{
  257. reject(res)
  258. }
  259. })
  260. })
  261. }
  262. /**
  263. *用户状态初始化
  264. */
  265. export function userInfoLogin(params) {
  266. return new Promise(function(resolve,reject) {
  267. request.post('/club/authorization',params,false, res => {
  268. if(res.code == 0 || res.code == 4){
  269. resolve(res)
  270. }else if(res.code == -6){
  271. resolve(res)
  272. }else{
  273. reject(res)
  274. }
  275. })
  276. })
  277. }
  278. /**
  279. *手机修改密码
  280. */
  281. export function mobilePassword(params) {
  282. return new Promise(function(resolve,reject) {
  283. if( params.mobileOrEmail == ''){
  284. uni.showToast({title: '请输入手机号',duration: 2000,mask:true,icon:'none'})
  285. return
  286. }
  287. if(!$reg.isMobile(params.mobileOrEmail)){
  288. uni.showToast({title: '手机格式不正确',duration: 2000,mask:true,icon:'none'})
  289. return
  290. }
  291. if( params.activateCode == ''){
  292. uni.showToast({title: '请输入手机验证码',duration: 2000,mask:true,icon:'none'})
  293. return
  294. }
  295. if(!$reg.isMobileCode(params.activateCode)){
  296. uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
  297. return
  298. }
  299. if( params.passWord == ''){
  300. uni.showToast({title: '请输入密码',duration: 2000,mask:true,icon:'none'})
  301. return
  302. }
  303. if(!$reg.checkPwd(params.passWord)){
  304. uni.showToast({title: '密码必须为8-16位字母数字的组合',duration: 2000,mask:true,icon:'none'})
  305. return
  306. }
  307. if( params.confirmPwd == ''){
  308. uni.showToast({title: '请再次确认密码',duration: 2000,mask:true,icon:'none'})
  309. return
  310. }
  311. if( params.confirmPwd !== params.passWord){
  312. uni.showToast({title: '两次输入的密码不一致',duration: 2000,mask:true,icon:'none'})
  313. return
  314. }
  315. request.post('/user/findCompanyPwd',params, true,res => {
  316. if(res.code == 0){
  317. resolve(res)
  318. }else{
  319. reject(res)
  320. }
  321. })
  322. })
  323. }
  324. /**
  325. *邮箱修改密码
  326. */
  327. export function emailPassword(params) {
  328. return new Promise(function(resolve,reject) {
  329. if( params.mobileOrEmail == ''){
  330. uni.showToast({title: '请输入邮箱',duration: 2000,mask:true,icon:'none'})
  331. return
  332. }
  333. if(!$reg.isEmail(params.mobileOrEmail)){
  334. uni.showToast({title: '请输入正确的邮箱地址',duration: 2000,mask:true,icon:'none'})
  335. return
  336. }
  337. if( params.activateCode == ''){
  338. uni.showToast({title: '请输入邮箱验证码',duration: 2000,mask:true,icon:'none'})
  339. return
  340. }
  341. if(!$reg.isEmailCode(params.activateCode)){
  342. uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
  343. return
  344. }
  345. if( params.passWord == ''){
  346. uni.showToast({title: '请输入密码',duration: 2000,mask:true,icon:'none'})
  347. return
  348. }
  349. if(!$reg.checkPwd(params.passWord)){
  350. uni.showToast({title: '密码必须为8-16位字母数字的组合',duration: 2000,mask:true,icon:'none'})
  351. return
  352. }
  353. if( params.confirmPwd == ''){
  354. uni.showToast({title: '请再次确认密码',duration: 2000,mask:true,icon:'none'})
  355. return
  356. }
  357. if( params.confirmPwd !== params.passWord){
  358. uni.showToast({title: '两次输入的密码不一致',duration: 2000,mask:true,icon:'none'})
  359. return
  360. }
  361. request.post('/user/findCompanyPwd',params,true, res => {
  362. if(res.code == 0){
  363. resolve(res)
  364. }else{
  365. reject(res)
  366. }
  367. })
  368. })
  369. }