use.js 9.8 KB

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