Authored by ping

update

... ... @@ -10,6 +10,9 @@ package com.yoho.activity.common.constatns;
* 2016年3月8日
*/
public class Constant {
//调用接口,成功的返回码
public static final int CODE_SUCCESS = 200;
//是否执行定时任务
public static boolean EXECUTE_TASK = true;
... ...
... ... @@ -24,6 +24,23 @@ public final class DateUtils {
}
/**
* 按照格式,取得当前时间
* @param str
* @return
*/
public static String getToday(String str) {
return getDateFormatStr(new Date(), str);
}
/**
* 获取今天的日期时间(yyyy-MM-dd HH:mm:ss)
* @return
*/
public static String getcurrentDateTime() {
return getToday(DEFAULT_FOMARTPATTER);
}
/**
*
* @param time 获取数据库中的UNIX_Time(该时间是距离1970年的秒数,在转换过程中先要换算成毫秒)中的月份信息
* @return
... ...
... ... @@ -9,7 +9,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.service.ICocacolaService;
... ... @@ -48,68 +47,24 @@ public class CocacolaController {
/**
* 验证验证码
* @param regCode
* 该方法会执行后续一系列动作
* 1、验证验证码
* 2、查询该手机号是否已经领取过该优惠券。如果已经领取,直接提示已经领取过;
* 3、如果未领取,则判断该手机号码是否注册过有货账号,如果没有,则调用注册接口,注册。
* 4、调用接口发送优惠券
* 5、如果用户是新用户,则发送短信提醒用户。
* @param code
* @param area
* @param mobile
* @param client_id
* @return
* @throws ServiceException
*/
@RequestMapping("/validRegCode")
public ApiResponse validRegCode(String regCode, String area, String mobile) throws ServiceException {
log.info("validRegCode with regCode={},area={}, mobile={},", regCode, area, mobile);
ApiResponse response = cocacolaService.validRegCode(regCode, area, mobile);
log.info("validRegCode with regCode={}, area={}, mobile={}, response={}",regCode, area, mobile, response);
return response;
}
/**
* 注册<br>
* <ul>
* <li>根据手机号码,查询用户是否注册</li>
* <li>调用注册</li>
* <li>使用redis(新注册人数领取人数,已注册用户领取人数)</li>
* @param area
* @param mobile
* @param client_type
* @return
* @throws ServiceException
*/
@RequestMapping("/register")
public ApiResponse register(String area, String mobile, String client_type) throws ServiceException {
log.info("register with area={}, mobile={}, client_type={} ", area, mobile, client_type);
ApiResponse response = cocacolaService.register(area, mobile, client_type);
log.info("register with area={}, mobile={}, client_type={}, response={}",area, mobile, client_type, response);
return response;
}
/**
* 发送优惠券
* @param uid
* @return
* @throws ServiceException
*/
@RequestMapping("/sendCoupon")
@ResponseBody
public ApiResponse sendCoupon(String uid) throws ServiceException{
log.info("sendCoupon with uid={}", uid);
ApiResponse response = cocacolaService.sendCoupon(uid);
log.info("sendSms response={}",response);
return response;
}
/**
* 给用户手机发送短信提醒
* @param mobile
* @param password
* @return
* @throws ServiceException
*/
@RequestMapping("/sendNoticeSms")
@ResponseBody
public ApiResponse sendNoticeSms(String mobile,String password) throws ServiceException{
log.info("sendNoticeSms with mobile={},password={},area={}", mobile,password);
ApiResponse response = cocacolaService.sendNoticeSms(mobile, password);
log.info("sendNoticeSms response={}",response);
@RequestMapping("/validRegCodeAndSendCode")
public ApiResponse validRegCodeAndSendCode(String code, String area, String mobile, String client_id) throws ServiceException {
log.info("validRegCodeAndSendCode with code={},area={}, mobile={},", code, area, mobile);
ApiResponse response = cocacolaService.validCodeAndSendCode(code, area, mobile, client_id);
log.info("validRegCodeAndSendCode with code={}, area={}, mobile={}, response={}",code, area, mobile, response);
return response;
}
... ...
... ... @@ -4,7 +4,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.0.6-SNAPSHOT</version>
<version>1.0.7-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
... ...
... ... @@ -25,13 +25,20 @@ public interface ICocacolaService {
/**
* 验证验证码
* @param regCode
* 该方法会执行后续一系列动作
* 1、验证验证码
* 2、查询该手机号是否已经领取过该优惠券。如果已经领取,直接提示已经领取过;
* 3、如果未领取,则判断该手机号码是否注册过有货账号,如果没有,则调用注册接口,注册。
* 4、调用接口发送优惠券
* 5、如果用户是新用户,则发送短信提醒用户。
* @param code
* @param area
* @param mobile
* @param client_id
* @return
* @throws ServiceException
*/
public ApiResponse validRegCode(String regCode, String area, String mobile) throws ServiceException;
public ApiResponse validCodeAndSendCode(String code, String area, String mobile, String client_id) throws ServiceException;
/**
* 注册
... ... @@ -46,10 +53,10 @@ public interface ICocacolaService {
/**
* 发送优惠券
*/
public ApiResponse sendCoupon(String uid) throws ServiceException;
public ApiResponse sendCoupon(int uid) throws ServiceException;
/**
* 发送短信通知用户
*/
public ApiResponse sendNoticeSms(String mobile,String password) throws ServiceException;
public void sendNoticeSms(String mobile,String password) throws ServiceException;
}
... ...
... ... @@ -17,15 +17,17 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSONObject;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.common.constatns.Constant;
import com.yoho.activity.common.helper.ClientSecretHelper;
import com.yoho.activity.common.utils.DateUtils;
import com.yoho.activity.common.utils.RandomUtil;
import com.yoho.activity.service.ICocacolaService;
import com.yoho.core.common.utils.MD5;
import com.yoho.core.redis.YHRedisTemplate;
import com.yoho.core.redis.YHValueOperations;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.promotion.request.ParamsConfigReq;
import com.yoho.service.model.promotion.response.EventConfigRsp;
... ... @@ -34,45 +36,43 @@ import com.yoho.service.model.request.RegisterReqBO;
import com.yoho.service.model.response.ProfileInfoRsp;
import com.yoho.service.model.response.RegisterRspBO;
/**
* 描述:
*
* @author ping.huang
* 2016年4月1日
* @author ping.huang 2016年4月1日
*/
@Service
public class CocacolaServiceImpl implements ICocacolaService {
static Logger log = LoggerFactory.getLogger(CocacolaServiceImpl.class);
static Logger cocacolaRegestLog = LoggerFactory.getLogger("cocacolaRegestLog");
@Resource
RestTemplate restTemplate;
@Resource
ClientSecretHelper clientSecretHelper;
@Value("${gateway.url}")
private String gatewayUrl;
private String gatewayUrl;
@Resource
private ServiceCaller service;
@Autowired
private YHValueOperations<String, String> yhValueOperations;
@Autowired
private YHRedisTemplate<String, String> yhRedisTemplate;
@Override
public ApiResponse sendSms(String area, String mobile) throws ServiceException {
log.debug("sendSms with area={}, mobile={}", area, mobile);
//检查参数
// 检查参数
if (StringUtils.isEmpty(mobile)) {
log.warn("sendSms error mobile is empty with area={}, mobile={}", area, mobile);
return new ApiResponse(501, "手机号不能为空");
}
//如果手机号中包含-符号,则说明是国际号
// 如果手机号中包含-符号,则说明是国际号
if (mobile.indexOf("-") > 0) {
String[] arr = mobile.split("-");
area = arr[0];
... ... @@ -81,33 +81,94 @@ public class CocacolaServiceImpl implements ICocacolaService {
if (StringUtils.isEmpty(area)) {
area = "86";
}
//组装请求对象,并生成client_secret
// 组装请求对象,并生成client_secret
Map<String, String> map = new HashMap<String, String>();
map.put("method", "app.passport.smsbind");
map.put("mobile", mobile);
map.put("area", area);
String param = clientSecretHelper.createClientSecret(map);
//调用gateway的发送验证码请求
// 调用gateway的发送验证码请求
return restTemplate.getForObject(gatewayUrl + "?" + param, ApiResponse.class);
}
@Override
public ApiResponse validRegCode(String regCode, String area, String mobile)throws ServiceException {
public ApiResponse validCodeAndSendCode(String code, String area, String mobile, String client_id) throws ServiceException {
log.debug("validRegCodeAndSendCode with code={}, area={}, mobile={}", code, area, mobile);
// 验证验证码
ApiResponse response = validRegCode(code, area, mobile);
if (Constant.CODE_SUCCESS != response.getCode()) {
log.warn("validCodeAndSendCode error validCode is error with code={}, area={}, mobile={}", code, area, mobile);
return response;
}
// 判断用户是否已经注册过,如果未注册,则调用注册接口
response = register(area, mobile, "web");
if (Constant.CODE_SUCCESS != response.getCode()) {
log.warn("validCodeAndSendCode error register error with code={}, area={}, mobile={}", code, area, mobile);
return response;
}
JSONObject registerJSON = (JSONObject) response.getData();
boolean newUser = registerJSON.getBooleanValue("newUser");
int uid = registerJSON.getIntValue("uid");
String password = registerJSON.getString("password");
// 调用接口,查询该用户是否已经领取过优惠券
// TODO
// ParamsConfigReq paramsConfigReq = new ParamsConfigReq();
// paramsConfigReq.setUid(Integer.valueOf(uid));
// paramsConfigReq.setEventCode("SEND_REGISTER_COUPON");
// paramsConfigReq.setClientType("web");
// paramsConfigReq.setType(1);
// boolean isSend = service.call("promotion.XXXXXXX", paramsConfigReq, Boolean.class);
// if (isSend) {
// log.warn("user has get coupon with area={}, mobile={}", area, mobile);
// return new ApiResponse(600, "对不起,您已经领过,请查看活动说明");
// }
//发送优惠券
response = sendCoupon(uid);
if (Constant.CODE_SUCCESS != response.getCode()) {
log.warn("validCodeAndSendCode error sendCoupon error with code={}, area={}, mobile={}", code, area, mobile);
return response;
}
//如果是新用户,则发送提醒短信
if (newUser) {
sendNoticeSms(mobile, password);
}
//调用成功,记录日志
JSONObject logJson = new JSONObject();
logJson.put("uid", uid);
logJson.put("client_id", client_id);
logJson.put("create_time", DateUtils.getcurrentDateTime());
logJson.put("mobile", mobile);
logJson.put("source", "kekoukele");
logJson.put("ip", "");
logJson.put("collect_ip", "");
logJson.put("isnew", newUser ? "Y" : "N");
cocacolaRegestLog.info(logJson.toString());
return response;
}
private ApiResponse validRegCode(String regCode, String area, String mobile) throws ServiceException {
log.debug("validRegCode with regCode={}, area={}, mobile={}", regCode, area, mobile);
// 检查参数 :验证码
if (StringUtils.isEmpty(regCode)) {
log.warn("validRegCode with regCode={}, area={}, mobile={}",regCode, area, mobile);
log.warn("validRegCode with regCode={}, area={}, mobile={}", regCode, area, mobile);
return new ApiResponse(501, "验证码不能为空");
}
// 检查参数 :手机号码
if (StringUtils.isEmpty(mobile)) {
log.warn("validRegCode with regCode={}, area={}, mobile={}",regCode, area, mobile);
log.warn("validRegCode with regCode={}, area={}, mobile={}", regCode, area, mobile);
return new ApiResponse(501, "手机号码不能为空");
}
}
// 如果手机号中包含-符号,则说明是国际号
if (mobile.indexOf("-") > 0) {
... ... @@ -119,29 +180,29 @@ public class CocacolaServiceImpl implements ICocacolaService {
area = "86";
}
//组装请求对象,并生成client_secret
// 组装请求对象,并生成client_secret
Map<String, String> map = new HashMap<String, String>();
map.put("method", "app.register.validRegCode");
map.put("code", regCode);
map.put("mobile", mobile);
map.put("area", area);
String param = clientSecretHelper.createClientSecret(map);
//调用gateway的发送验证码请求
// 调用gateway的发送验证码请求
return restTemplate.getForObject(gatewayUrl + "?" + param, ApiResponse.class);
}
@Override
public ApiResponse register(String area, String mobile,String client_type) throws ServiceException {
public ApiResponse register(String area, String mobile, String client_type) throws ServiceException {
log.debug("register with area={}, mobile={},client_type={}", area, mobile, client_type);
// 检查参数 :手机号码
if (StringUtils.isEmpty(mobile)) {
log.warn("register with area={}, mobile={}, client_type={}", area, mobile, client_type);
return new ApiResponse(501, "手机号码不能为空");
}
// 如果手机号中包含-符号,则说明是国际号
if (mobile.indexOf("-") > 0) {
String[] arr = mobile.split("-");
... ... @@ -151,17 +212,18 @@ public class CocacolaServiceImpl implements ICocacolaService {
if (StringUtils.isEmpty(area)) {
area = "86";
}
// 1.根据手机号码查询,用户是否注册
ProfileRequestBO bo = new ProfileRequestBO();
bo.setMobile(mobile);
bo.setArea(area);
bo.setCheckSSO(true);
ProfileInfoRsp result = service.call("users.getUserprofileByEmailOrMobile", bo, ProfileInfoRsp.class);
// 查询用户不存在
JSONObject json = new JSONObject();
if (result == null || result.getUid() == 0) {
json.put("newUser", true);
// 2.调用注册
RegisterReqBO registerReqBO = new RegisterReqBO();
registerReqBO.setArea(area);
... ... @@ -169,69 +231,63 @@ public class CocacolaServiceImpl implements ICocacolaService {
registerReqBO.setPassword(RandomUtil.autoGetPassword());
registerReqBO.setClient_type(client_type);
RegisterRspBO model = service.call("users.register", registerReqBO, RegisterRspBO.class);
json.put("password", registerReqBO.getPassword());
// 3.记录新注册用户 领取人数
try{
try {
yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1);
yhRedisTemplate.longExpire(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 30, TimeUnit.DAYS);
}catch (Exception e) {
log.warn("Redis exception. check get times. area is {}, mobile is {}, client_type={},exception is {}", area, mobile,client_type, e.getMessage());
} catch (Exception e) {
log.warn("Redis exception. check get times. area is {}, mobile is {}, client_type={},exception is {}", area, mobile, client_type, e.getMessage());
}
return new ApiResponse(model);
json.put("uid", model.getUid());
}
// 3.已注册用户,redis记录领取人数
else{
try{
else {
json.put("newUser", false);
try {
yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1);
yhRedisTemplate.longExpire(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 30, TimeUnit.DAYS);
}catch (Exception e) {
} catch (Exception e) {
log.warn("Redis exception. check get times. area is {}, mobile is {}, client_type={} exception is {}", area, mobile, client_type, e.getMessage());
}
return new ApiResponse();
json.put("uid", result.getUid());
}
return new ApiResponse(json);
}
@Override
public ApiResponse sendCoupon(String uid) throws ServiceException{
public ApiResponse sendCoupon(int uid) throws ServiceException {
log.info("sendCoupon with uid={}", uid);
// try {
ParamsConfigReq paramsConfigReq = new ParamsConfigReq();
paramsConfigReq.setUid(Integer.valueOf(uid));
paramsConfigReq.setEventCode("SEND_REGISTER_COUPON");
paramsConfigReq.setClientType("web");
paramsConfigReq.setType(1);
EventConfigRsp eventConfigRsp = service.call("promotion.sendCouponByConfig", paramsConfigReq, EventConfigRsp.class);
log.info("sendCoupon result is {}", eventConfigRsp);
// } catch (Exception e) {
// throw new ServiceException(ServiceError.PROMOTION_COUPON_SEND_FAIL);
// }
if(eventConfigRsp.getFlag()!=1){
throw new ServiceException(ServiceError.PROMOTION_COUPON_SEND_FAIL);
}else{
return new ApiResponse(200,"优惠券发送成功");
ParamsConfigReq paramsConfigReq = new ParamsConfigReq();
paramsConfigReq.setUid(Integer.valueOf(uid));
paramsConfigReq.setEventCode("SEND_COCACOLA_COUPON");
paramsConfigReq.setClientType("web");
paramsConfigReq.setType(1);
EventConfigRsp eventConfigRsp = service.call("promotion.sendCouponByConfig", paramsConfigReq, EventConfigRsp.class);
log.info("sendCoupon result is {}", eventConfigRsp);
if (eventConfigRsp.getFlag() != 1) {
log.warn("sendCoupon error with uid={}", uid);
return new ApiResponse(601, "优惠券领取失败");
} else {
return new ApiResponse(200, "优惠券领取成功");
}
}
@Override
public ApiResponse sendNoticeSms(String mobile,String password) throws ServiceException{
log.info("sendCoupon with mobile={},password={}", mobile,password);
//组装请求对象,并生成client_secret
public void sendNoticeSms(String mobile, String password) throws ServiceException {
log.info("sendCoupon with mobile={}", mobile);
// 组装请求对象,并生成client_secret
Map<String, String> map = new HashMap<String, String>();
map.put("method", "app.message.sendMsg");
map.put("username", "youhuo");
map.put("password", MD5.md5("I8vX4MtK"));
map.put("mobile", mobile);
map.put("codes", "123,"+mobile+","+password+"");
map.put("template", "mobile_coupon");
String param = clientSecretHelper.createClientSecret(map);
//调用gateway的发送短信请求
return restTemplate.getForObject(gatewayUrl + "?" + param, ApiResponse.class);
map.put("content", "【 Yoho!Buy有货】恭喜您获得一张……(优惠券名称),您的登录账号是 "+ mobile +", 密码是"+ password +";下载Yoho!Buy有货手机端 http://t.cn,更多惊喜等着您!【有货】");
map.put("productid", "333333");
// 调用接口发送短信请求
restTemplate.postForObject("http://www.ztsms.cn/sendSms.do", map, String.class);
}
}
... ...
... ... @@ -25,7 +25,7 @@ redis.proxy.auth=
execute.timetask.host=192.168.90.9
#zkAddress
zkAddress=127.0.0.1:2181
zkAddress=192.168.102.205:2181
# web context
web.context=activity
... ...
... ... @@ -102,6 +102,22 @@
</encoder>
</appender>
<!-- 可口可乐活动,注册日志-->
<appender name="COCACOLA_REGEST_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.home}/logs/%d{yyyy-MM-dd}/cocacola_regest.log</fileNamePattern>
<!-- 日志最大的保存天数 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${maxFileSize}</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- 数据库操作日志 -->
<logger name="java.sql.PreparedStatement" value="DEBUG" />
<logger name="java.sql.Connection" value="DEBUG" />
... ... @@ -148,5 +164,11 @@
<level value="DEBUG"/>
<appender-ref ref="DATABASE_STAT"/>
</logger>
<!--可口可乐注册日志-->
<logger name="cocacolaRegestLog" additivity="true">
<level value="INFO"/>
<appender-ref ref="COCACOLA_REGEST_LOG"/>
</logger>
</configuration>
\ No newline at end of file
... ...
... ... @@ -119,6 +119,24 @@
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- 可口可乐注册日志-->
<appender name="COCACOLA_REGEST_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${yoho.logs.basedir}/${yoho.activity.env.namespace}/cocacola_regest.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${yoho.logs.basedir}/${yoho.activity.env.namespace}/archived/cocacola_regest.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>${yoho.logs.maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- 数据库操作日志 -->
<logger name="java.sql.PreparedStatement" value="${yoho.logs.level}" />
... ... @@ -164,4 +182,9 @@
<level value="INFO"/>
<appender-ref ref="REQUEST_STAT"/>
</logger>
<!--可口可乐注册日志-->
<logger name="cocacolaRegestLog" additivity="true">
<level value="INFO"/>
<appender-ref ref="COCACOLA_REGEST_LOG"/>
</logger>
</configuration>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{cokeTitle}}</title>
<meta name="apple-mobile-web-app-title" content="SUMMER SALE">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui" media="(device-height: 568px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="grey">
<style type="text/css">
*{
margin: 0;
padding: 0;
font-size: 14px;
}
html,body{
width: 100%;
height: 100%;
}
.page{
width: 100%;
height: 100%;
overflow: hidden;
background: #e10c1e;
}
.banner{
width: 100%;
height: auto;
overflow: hidden;
}
.banner img{
width: 100%;
height: auto;
}
.centent{
width: 100%;
height: auto;
overflow: hidden;
padding-top: 2rem;
padding-bottom: .6rem;
}
.centent p{
width: 100%;
height: auto;
overflow: hidden;
text-align: center;
color: #fff;
line-height: 2rem;
font-size: .9rem
}
.centent p.phone{
font-size: 1.3rem;
font-weight: bold;
line-height: 2.6rem;
}
.coupon{
width: 81.25%;
height: auto;
overflow: hidden;
margin: 0 auto;
}
.coupon img{
width: 100%;
height: auto;
}
.dialog{
width: 82%;
height: 14rem;
position: absolute;
background: #fff;
border-radius: .6rem;
left:9%;
top: 45%;
margin-top: -7rem;
z-index: 2;
}
.dialog .close{
width: 1.4rem;
height: 1.4rem;
background: #444;
color: #f1f1f1;
border-radius: 50%;
position: absolute;
top: -.5rem;
right: -.5rem;
line-height: 1.4rem;
text-align: center;
}
.dialog .inform{
width: 100%;
height: 6rem;
overflow: hidden;
text-align: center;
padding-top: 1.5rem;
line-height: 2.4rem;
}
.dialog .inform h3{
font-size: 1.5rem;
}
.dialog .inform span{
font-size: 1rem;
}
.dialog .btn-list{
width: 110%;
height: 3.4rem;
overflow: hidden;
border-top: 1px solid #c5c5c5;
}
.btn-list span{
width: 45.5%;
height: 3.4rem;
overflow: hidden;
float: left;
border-right: 1px solid #c5c5c5;
line-height: 3.4rem;
text-align: center;
font-size: 1.2rem;
}
.hidden{
display: none;
}
.keep-out{
width: 100%;
height: 100%;
overflow: height;
background-color: #000;
opacity: 0.4;
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
.activity-message{
overflow: auto;
}
.activity-message h3{
width: 100%;
height: 3.4rem;
padding-top: .6rem;
line-height: 3.4rem;
font-size: 1.2rem;
text-align: center;
}
.activity-message p{
width: 85%;
height: auto;
overflow: hidden;
margin:0 auto;
line-height: 2rem;
}
.footer{
width: 100%;
height: auto;
overflow: hidden;
}
.footer .btn{
width: 81.25%;
height:auto;
margin: 0 auto .6rem;
}
.footer .btn img{
width: 100%;
height: auto;
}
.footer span{
font-weight: bold;
display: inline-block;
width: 20%;
height: auto;
text-align: center;
color: #fff;
margin: 0 40%;
}
</style>
</head>
<body>
<div class="page">
<div class="banner">
<img src="images/cokeBanner.jpg">
</div>
<div class="centent">
<div class="coupon">
<img src="images/cokeCoupon.png">
</div>
<p class="phone">优惠券已放至账户{{phone}}</p>
<p>登录Yoho!Buy有货客户端即可使用</p>
</div>
<div class="footer">
<div class="btn">
<img src="images/cokeBtn.png">
</div>
<span>活动说明</span>
</div>
</div>
<div class="dialog hidden" style="height: 11rem;" id="dialog">
<div class="content" style="overflow: hidden;">
<div class="inform">
<h3>恭喜您成功领取</h3>
<span>Yoho!Buy有货优惠券</span>
</div>
<div class="btn-list">
<span>下载Yoho!Buy有货</span>
<span style="color: red;">我知道了</span>
</div>
</div>
</div>
<div class="keep-out hidden"></div>
<div class="dialog hidden" id="message">
<span class="close">X</span>
<div class="activity-message">
<h3>活动说明</h3>
<div class="message">
<P>1、活动时间:2016年4月7日到2016年7月7日</P>
<P>2、仅限新注册用户以及首次购买用户使用</P>
<P>3、同一手机号限领一次优惠券</P>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$('.close').on('click', function(){
$('.dialog').addClass('hidden');
$('.keep-out').addClass('hidden');
$('#dialog .content').html(' ')
})
$('.footer span').on('click',function(){
$('#message').removeClass('hidden');
$('.keep-out').removeClass('hidden');
})
setTimeout(function(){
$('#dialog').removeClass('hidden');
$('.keep-out').removeClass('hidden');
},1000)
$('.btn-list span:eq(1)').on('click',function(){
$('.dialog').addClass('hidden');
$('.keep-out').addClass('hidden');
})
</script>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{cokeTitle}}</title>
<meta name="apple-mobile-web-app-title" content="SUMMER SALE">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui" media="(device-height: 568px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="grey">
<style type="text/css">
*{
margin: 0;
padding: 0;
font-size: 14px;
}
html,body{
width: 100%;
height: 100%;
}
.page{
width: 100%;
height: 100%;
overflow: hidden;
background: #e10c1e;
}
.banner{
width: 100%;
height: auto;
overflow: hidden;
}
.footer{
width: 100%;
height: auto;
overflow: hidden;
position: relative;
}
.footer img, .banner img{
width: 100%;
}
.footer span{
position: absolute;
bottom: 0;
left: 40%;
width: 20%;
height: 2rem;
}
.centent{
width: 100%;
height: auto;
overflow: hidden;
padding-top: 4rem;
}
.centent div{
width: 81.25%;
height: 4rem;
overflow: hidden;
margin: 0 auto;
padding-bottom: 1.2rem;
}
.centent input{
width: 68%;
height: 3.6rem;
overflow: hidden;
border: 1px solid #fff;
border-right: none;
background: none;
font-size: 18px;
color: #fff;
float: left;
box-sizing: border-box;
border-radius: .3rem 0 0 .3rem;
text-align: center;
outline:none
}
.centent span{
width: 30%;
height: 3.6rem;
float: left;
line-height: 3.6rem;
text-align: center;
font-size: 1em;
border-radius: 0 .3rem .3rem 0;
background: #b0b0b0;
color: #e0e0e0;
}
.centent .verification-code,.centent .get{
background: #fff;
color: #000;
}
.dialog{
width: 82%;
height: 14rem;
position: absolute;
background: #fff;
border-radius: .6rem;
left:9%;
top: 45%;
margin-top: -7rem;
z-index: 2;
}
.dialog .close{
width: 1.4rem;
height: 1.4rem;
background: #444;
color: #f1f1f1;
border-radius: 50%;
position: absolute;
top: -.5rem;
right: -.5rem;
line-height: 1.4rem;
text-align: center;
}
.hidden{
display: none;
}
.phone-error{
text-align: center;
line-height: 14rem;
}
.keep-out{
width: 100%;
height: 100%;
overflow: height;
background-color: #000;
opacity: 0.4;
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
.activity-message{
overflow: auto;
}
.activity-message h3{
width: 100%;
height: 3.4rem;
padding-top: .6rem;
line-height: 3.4rem;
font-size: 1.2rem;
text-align: center;
}
.activity-message p{
width: 85%;
height: auto;
overflow: hidden;
margin:0 auto;
line-height: 2rem;
}
</style>
</head>
<body>
<div class="page">
<div class="banner">
<img src="images/cokeBanner.jpg">
</div>
<div class="centent">
<div>
<input id="phone" type="text" placeholder="请输入手机号" maxlength="11"/>
<span>获取验证码</span>
</div>
<div>
<input id="verification" type="text" placeholder="请输入手机验证码" maxlength="6"/>
<span>领取</span>
</div>
</div>
<div class="footer">
<img src="images/cokefooter.jpg">
<span></span>
</div>
</div>
<div class="dialog hidden" id="dialog">
<span class="close">X</span>
<div class="content"></div>
</div>
<div class="keep-out hidden"></div>
<div class="dialog hidden" id="message">
<span class="close">X</span>
<div class="activity-message">
<h3>活动说明</h3>
<div class="message">
<P>1、活动时间:2016年4月7日到2016年7月7日</P>
<P>2、仅限新注册用户以及首次购买用户使用</P>
<P>3、同一手机号限领一次优惠券</P>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
var num = 0;
$('#phone').focus(function(){
$('.centent span').eq('0').addClass('verification-code');
})
$('#phone').blur(function(){
if (!$(this).val()) {
$('.centent span').eq('0').removeClass();
}
})
$('#verification').focus(function(){
$('.centent span').eq('1').addClass('get');
})
$('#verification').blur(function(){
if (!$(this).val()) {
$('.centent span').eq('1').removeClass();
}
})
$('.centent').on('click', '.verification-code', function(){
if ($(this).siblings('input').val().length === 11) {
$.ajax({
url:'',
dataType:'json',
success:function(data){
if (data.code === 200) {
var time = setInterval(function(){
num++;
if (num > 60) {
clearInterval('time');
$('.centent span').eq('0').addClass('verification-code').html('获取验证码');
} else {
$('.centent span').eq('0').removeClass('verification-code').html('重新发送(' + (60-num) + ')');
}
},1000);
}
}
})
} else {
$('#dialog').removeClass('hidden');
$('.keep-out').removeClass('hidden');
$('#dialog .content').html('<p class="phone-error">手机号错误,请重新输入。<p>');
}
});
$('.centent').on('click', '.get', function(){
if ($(this).siblings('input').val().length === 6) {
$.ajax({
url:'',
dataType:'json',
success:function(data){
if (data.code === 200) {
} else {
$('#dialog').removeClass('hidden');
$('.keep-out').removeClass('hidden');
$('#dialog .content').html('<p class="phone-error">'+ data.message +'<p>');
}
}
})
} else {
$('#dialog').removeClass('hidden');
$('.keep-out').removeClass('hidden');
$('#dialog .content').html('<p class="phone-error">验证码错误,请重新输入。<p>');
}
});
$('.close').on('click', function(){
$('.dialog').addClass('hidden');
$('.keep-out').addClass('hidden');
$('#dialog .content').html(' ')
})
$('.footer span').on('click',function(){
$('#message').removeClass('hidden');
$('.keep-out').addClass('hidden');
})
</script>
</html>
\ No newline at end of file
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}
var config = $.cookie = function (key, value, options) {
// Write
if (value !== undefined && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setTime(+t + days * 864e+5);
}
return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// Read
var result = key ? undefined : {};
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');
if (key && key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}
// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) === undefined) {
return false;
}
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};
}));
... ...