**标黄
export default {
data () {
return {
msg: "这是一个变量",
xx:"",
}
},
mounted : function(){
var username = $.cookie("username")
$("#user").html(username)
//获取url中的参数
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]); return null; //返回参数值
}
var xx = getUrlParam('id');
let params = new URLSearchParams();
params.append('id',xx)
//每个商品的信息
this.axios({
url:'http://127.0.0.1:8000/userctrl/good_info',
method:'post',
data:params,
responseType:"json",
})
.then(function(obj){
}) methods:{
shuochang:
function(){
if($("#haha").text() == "收藏宝贝"){
let params = new URLSearchParams();
params.append('id',this.xx)
params.append('username',$.cookie("username"))
this.axios({
url:'http://127.0.0.1:8000/userctrl/good_shou',
method:'post',
data:params,
responseType:"text",
}) .then(function(obj){
if(obj.data="ok"){alert("收藏成功")
$("#haha").html('已收藏')
}
})
}
export default {
data () {
return {
username:'ha',
b:'',
}
},
mounted:function(){
$("#username").html($.cookie('username'));
var that = this;
//渲染商品
this.axios({
//指定请求地址
url:'http://127.0.0.1:8000/userctrl/showseckill',
//请求参数
// data:param,
//请求类型
method:'POST',
//接口返回值类型
responseType:'json'
})
.then(function(obj){
that.b = obj.data[0].pk;
}),
methods:{
qiang:
function(){
let params = new URLSearchParams();
params.append('id',this.b)
params.append('user',$.cookie('username'))
this.axios({
url:'http://127.0.0.1:8000/userctrl/good_qiang',
method:'post',
data:params,
responseType:"text",
}) .then(function(obj){
})