Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_60613409
vue2-elm
提交
c27b5929
V
vue2-elm
项目概览
m0_60613409
/
vue2-elm
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue2-elm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c27b5929
编写于
12月 26, 2016
作者:
M
maguohua
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updata
上级
3dc1b6d7
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
71 addition
and
106 deletion
+71
-106
src/config/fetch.js
src/config/fetch.js
+1
-1
src/main.js
src/main.js
+2
-44
src/page/home/index.vue
src/page/home/index.vue
+10
-1
src/router/router.js
src/router/router.js
+1
-0
src/service/getData.js
src/service/getData.js
+3
-4
src/service/setPromise.js
src/service/setPromise.js
+1
-1
src/store/action.js
src/store/action.js
+4
-18
src/store/getters.js
src/store/getters.js
+3
-0
src/store/index.js
src/store/index.js
+8
-4
src/store/modules/checkout/index.js
src/store/modules/checkout/index.js
+32
-0
src/store/mutation-types.js
src/store/mutation-types.js
+2
-0
src/store/mutations.js
src/store/mutations.js
+4
-33
未找到文件。
src/config/fetch.js
浏览文件 @
c27b5929
import
{
baseUrl
}
from
'
./env
'
export
default
(
type
=
'
GET
'
,
url
=
''
,
data
=
{})
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
//
定义
一个promise
return
new
Promise
((
resolve
,
reject
)
=>
{
//
返回
一个promise
type
=
type
.
toUpperCase
();
url
=
baseUrl
+
url
let
requestObj
=
{
...
...
src/main.js
浏览文件 @
c27b5929
...
...
@@ -2,57 +2,15 @@ import Vue from 'vue'
import
VueRouter
from
'
vue-router
'
import
routes
from
'
./router/router
'
import
store
from
'
./store/
'
import
ajax
from
'
./config/ajax
'
import
fetch
from
'
./config/fetch
'
import
{
routerMode
}
from
'
./config/env
'
import
'
./style/common.scss
'
import
'
./config/rem
'
import
{
cityGuess
}
from
'
./service/getData
'
cityGuess
().
then
(
res
=>
{
console
.
log
(
res
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
// fetch('GET', '/shopping/restaurants',{
// latitude: 31.16407,
// longitude: 121.38876,
// offset: 0,
// limit: 20,
// 'extras[]': 'activities',
// })
// ajax('get', '/v2/index_entry', {
// geohash: 'wtw3630xg5e',
// group_type: 1,
// 'flags[]': 'F',
// })
// var obj = {
// mobile: '13681711254',
// scene: 'login',
// type: 'sms',
// }
// fetch('POST', '/v4/mobile/verify_code/send', obj)
// var loginObj = {
// code:567052,
// mobile: '13681711254',
// validate_token: '6a869f38c6d0a0bb5b023b35c5e35ceef8d710c1502369d56709b1632df830f8'
// }
// fetch('POST', '/v1/login/app_mobile', loginObj)
Vue
.
use
(
VueRouter
)
const
router
=
new
VueRouter
({
routes
,
mode
:
routerMode
,
routes
strict
:
process
.
env
.
NODE_ENV
!==
'
production
'
})
new
Vue
({
...
...
src/page/home/index.vue
浏览文件 @
c27b5929
...
...
@@ -15,9 +15,18 @@
</
template
>
<
script
>
import
{
cityGuess
}
from
'
../../service/getData
'
export
default
{
created
(){
// cityGuess().then(res => {
// console.log(res)
// }).catch(err => {
// console.log(err)
// })
this
.
$store
.
dispatch
(
'
getData
'
)
}
}
</
script
>
...
...
src/router/router.js
浏览文件 @
c27b5929
import
App
from
'
../App
'
const
home
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
'
../page/home
'
)),
'
home
'
)
const
city
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
'
../page/city
'
)),
'
city
'
)
const
msite
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
'
../page/msite
'
)),
'
msite
'
)
...
...
src/service/getData.js
浏览文件 @
c27b5929
import
setPromise
from
'
./setPromise
'
import
fetch
from
'
../config/fetch
'
/**
* 获取首页默认地址
*/
const
cityGuess
=
(
type
=
'
GET
'
,
url
=
'
/v1/cities
'
,
data
=
{
type
:
'
guess
'
})
=>
{
return
setPromise
(
type
,
url
,
data
)
}
const
cityGuess
=
()
=>
fetch
(
'
GET
'
,
'
/v1/cities
'
,
{
type
:
'
guess
'
})
export
{
cityGuess
}
\ No newline at end of file
src/service/setPromise.js
浏览文件 @
c27b5929
import
fetch
from
'
../config/fetch
'
export
default
(
type
,
url
,
data
)
=>
{
export
default
(
type
=
'
GET
'
,
url
=
''
,
data
=
{}
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fetch
(
type
,
url
,
data
).
then
(
res
=>
{
resolve
(
res
)
...
...
src/store/action.js
浏览文件 @
c27b5929
import
ajax
from
'
../config/ajax
'
import
{
cityGuess
}
from
'
../service/getData
'
import
{
GET_DATA
}
from
'
./mutation-types.js
'
export
default
{
addNum
({
commit
,
state
},
id
)
{
commit
(
'
REMBER_ANSWER
'
,
{
id
})
if
(
state
.
itemNum
<
state
.
itemDetail
.
length
)
{
commit
(
'
ADD_ITEMNUM
'
,
{
num
:
1
})
}
},
getData
({
commit
,
state
})
{
ajax
(
'
GET
'
,
'
http://operating-activities.putao.com/happyfriday?active_topic_id=4
'
).
then
(
res
=>
{
commit
(
'
GET_DATA
'
,
{
res
})
cityGuess
().
then
(
res
=>
{
commit
(
GET_DATA
,
{
data
:
res
})
})
},
initializeData
({
commit
})
{
commit
(
'
INITIALIZE_DATA
'
)
}
}
\ No newline at end of file
src/store/getters.js
0 → 100644
浏览文件 @
c27b5929
export
default
{
}
\ No newline at end of file
src/store/index.js
浏览文件 @
c27b5929
...
...
@@ -2,17 +2,21 @@ import Vue from 'vue'
import
Vuex
from
'
vuex
'
import
mutations
from
'
./mutations
'
import
actions
from
'
./action
'
import
ajax
from
'
../config/ajax
'
import
getters
from
'
./getters
'
import
checkout
from
'
./modules/checkout
'
Vue
.
use
(
Vuex
)
const
state
=
{
test1
:
null
}
export
default
new
Vuex
.
Store
({
state
,
getters
,
actions
,
mutations
mutations
,
modules
:
{
checkout
,
}
})
\ No newline at end of file
src/store/modules/checkout/index.js
0 → 100644
浏览文件 @
c27b5929
import
{
GET_DATA2
}
from
'
../../mutation-types
'
import
{
cityGuess
}
from
'
../../../service/getData
'
const
state
=
{
test2
:
null
}
const
getters
=
{
}
const
mutations
=
{
[
GET_DATA2
]
(
state
,
{
data
})
{
console
.
log
(
data
)
state
.
test2
=
data
},
}
const
actions
=
{
getData2
({
commit
,
state
})
{
cityGuess
().
then
(
res
=>
{
commit
(
GET_DATA2
,
{
data
:
res
})
})
},
}
export
default
{
state
,
getters
,
mutations
,
actions
}
\ No newline at end of file
src/store/mutation-types.js
0 → 100644
浏览文件 @
c27b5929
export
const
GET_DATA
=
'
GET_DATA
'
export
const
GET_DATA2
=
'
GET_DATA2
'
\ No newline at end of file
src/store/mutations.js
浏览文件 @
c27b5929
const
GET_DATA
=
'
GET_DATA
'
const
ADD_ITEMNUM
=
'
ADD_ITEMNUM
'
const
REMBER_ANSWER
=
'
REMBER_ANSWER
'
const
REMBER_TIME
=
'
REMBER_TIME
'
const
INITIALIZE_DATA
=
'
INITIALIZE_DATA
'
const
GET_USER_INFORM
=
'
GET_USER_INFORM
'
import
{
GET_DATA
}
from
'
./mutation-types.js
'
export
default
{
[
GET_DATA
](
state
,
payload
)
{
if
(
payload
.
res
.
httpStatusCode
==
200
)
{
state
.
itemDetail
=
payload
.
res
.
topiclist
;
}
},
[
GET_USER_INFORM
](
state
,
payload
)
{
state
.
user_id
=
payload
.
res
.
users_id
;
},
[
ADD_ITEMNUM
](
state
,
payload
)
{
state
.
itemNum
+=
payload
.
num
;
},
[
REMBER_ANSWER
](
state
,
payload
)
{
state
.
answerid
[
state
.
itemNum
]
=
payload
.
id
;
},
[
REMBER_TIME
](
state
)
{
state
.
timer
=
setInterval
(()
=>
{
state
.
allTime
++
;
},
1000
)
},
[
INITIALIZE_DATA
](
state
)
{
state
.
itemNum
=
1
;
state
.
allTime
=
0
;
[
GET_DATA
]
(
state
,
{
data
})
{
console
.
log
(
data
)
state
.
test1
=
data
},
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录