#!/bin/bash
ip=$1
phone_no=$2
registerFrom=$3
date=`date "+%Y-%m-%d %H:%M:%S"`

#"请输入用户手机号:" phone_no
len=`echo $phone_no|awk '{print length($0)}'`
if [ $len -ne 11 ];then
	echo "请输入11位手机号!"
	exit -1
fi

if [ -z "$registerFrom" ];then
	registerFrom=214
fi

#ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
resp=`curl "http://$ip:7037/app/login?registerFrom=$registerFrom&phoneNo=$phone_no" 2>/dev/null`
result=$(echo $resp | grep "成功")
if [ -n "$result" ];then
	token=`echo $resp | jq ".data.token" | sed "s/\"//g"`
	#echo "token: $token"
	echo "$date http://$ip:7001/app-landing?token=$token&registerFrom=$registerFrom&channelId=1"
else
	echo "获取token失败，请检查$ip的xyqb和cash-loan-flow"
fi
