use.js 9.5 KB

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